Skip to content

Commit a3dc7e1

Browse files
theanarkhjuanarbol
authored andcommitted
src: fix uv_err_name memory leak
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]>
1 parent a711080 commit a3dc7e1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

‎src/uv.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ void ErrName(const FunctionCallbackInfo<Value>& args){
7373
int err;
7474
if (!args[0]->Int32Value(env->context()).To(&err)) return;
7575
CHECK_LT(err, 0);
76-
constchar* name = uv_err_name(err);
76+
char name[50];
77+
uv_err_name_r(err, name, sizeof(name));
7778
args.GetReturnValue().Set(OneByteString(env->isolate(), name));
7879
}
7980

‎test/parallel/test-uv-errno.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const{internalBinding } = require('internal/test/binding');
1212
constuv=internalBinding('uv');
1313
constkeys=Object.keys(uv);
1414

15+
assert.strictEqual(uv.errname(-111111),'Unknown system error -111111');
16+
1517
keys.forEach((key)=>{
1618
if(!key.startsWith('UV_'))
1719
return;

0 commit comments

Comments
(0)