diff --git a/src/uv.cc b/src/uv.cc index 2b0c424587e420..10f083b334d71f 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -73,7 +73,8 @@ void ErrName(const FunctionCallbackInfo& 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)); } diff --git a/test/parallel/test-uv-errno.js b/test/parallel/test-uv-errno.js index e46b365e4b69e4..f30518fb474657 100644 --- a/test/parallel/test-uv-errno.js +++ b/test/parallel/test-uv-errno.js @@ -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;