Skip to content

Commit f3a8740

Browse files
committed
src: fix uv_err_name memory leak
1 parent ab89024 commit f3a8740

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/util.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,6 @@ void SetConstructorFunction(v8::Local<v8::Context> context,
922922
v8::Local<v8::FunctionTemplate> tmpl,
923923
SetConstructorFunctionFlag flag =
924924
SetConstructorFunctionFlag::SET_CLASS_NAME);
925-
926925
} // namespace node
927926

928927
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

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-
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

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
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)