Skip to content

Commit

Permalink
src: fix uv_err_name memory leak
Browse files Browse the repository at this point in the history
PR-URL: #44421
Refs: #44401
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
  • Loading branch information
theanarkh authored and RafaelGSS committed Sep 6, 2022
1 parent aea9336 commit 406baab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/uv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void ErrName(const FunctionCallbackInfo<Value>& args) {
int err;
if (!args[0]->Int32Value(env->context()).To(&err)) return;
CHECK_LT(err, 0);
const char* name = uv_err_name(err);
char name[50];
uv_err_name_r(err, name, sizeof(name));
args.GetReturnValue().Set(OneByteString(env->isolate(), name));
}

Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-uv-errno.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const { internalBinding } = require('internal/test/binding');
const uv = internalBinding('uv');
const keys = Object.keys(uv);

assert.strictEqual(uv.errname(-111111), 'Unknown system error -111111');

keys.forEach((key) => {
if (!key.startsWith('UV_'))
return;
Expand Down

0 comments on commit 406baab

Please sign in to comment.