mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
bindings: close after reading module struct
Do not let the module struct to be deallocated by `uv_dlclose` before reading data from it. PR-URL: https://github.com/nodejs/node/pull/2792 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
This commit is contained in:
parent
3ee7fbcefd
commit
b73ff52fe6
|
|
@ -2120,12 +2120,15 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
|||
return;
|
||||
}
|
||||
if (mp->nm_version != NODE_MODULE_VERSION) {
|
||||
uv_dlclose(&lib);
|
||||
char errmsg[1024];
|
||||
snprintf(errmsg,
|
||||
sizeof(errmsg),
|
||||
"Module version mismatch. Expected %d, got %d.",
|
||||
NODE_MODULE_VERSION, mp->nm_version);
|
||||
|
||||
// NOTE: `mp` is allocated inside of the shared library's memory, calling
|
||||
// `uv_dlclose` will deallocate it
|
||||
uv_dlclose(&lib);
|
||||
env->ThrowError(errmsg);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user