Skip to content

Commit 9683e5d

Browse files
indutnyrvagg
authored andcommitted
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: #2792 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
1 parent 82ba183 commit 9683e5d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/node.cc

+4-1
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
}

0 commit comments

Comments
 (0)