bindings: close after reading module struct · nodejs/node@9683e5d

Original file line numberDiff line numberDiff line change

@@ -2087,12 +2087,15 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {

20872087

return;

20882088

}

20892089

if (mp->nm_version != NODE_MODULE_VERSION) {

2090-

uv_dlclose(&lib);

20912090

char errmsg[1024];

20922091

snprintf(errmsg,

20932092

sizeof(errmsg),

20942093

"Module version mismatch. Expected %d, got %d.",

20952094

NODE_MODULE_VERSION, mp->nm_version);

2095+
2096+

// NOTE: `mp` is allocated inside of the shared library's memory, calling

2097+

// `uv_dlclose` will deallocate it

2098+

uv_dlclose(&lib);

20962099

env->ThrowError(errmsg);

20972100

return;

20982101

}