Skip to content

Commit 63aba56

Browse files
authored
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 0633e9a commit 63aba56

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/uv.cc

+2-1
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-
const char* 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

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const { internalBinding } = require('internal/test/binding');
1212
const uv = internalBinding('uv');
1313
const keys = 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)