src: fix uv_err_name memory leak

PR-URL: https://github.com/nodejs/node/pull/44421
Refs: https://github.com/nodejs/node/pull/44401
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
theanarkh authored and GitHub committed 2022-08-30 18:33:40 +00:00
1 parent 0633e9a0b5
commit 63aba5672c
2 files changed
+4 -1

No files matched your search

+2 -1
View File
@@ -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));
}
+2
View File
@@ -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;