Skip to content

Commit b73ff52

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 3ee7fbc commit b73ff52

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
@@ -2120,12 +2120,15 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
21202120
return;
21212121
}
21222122
if (mp->nm_version != NODE_MODULE_VERSION) {
2123-
uv_dlclose(&lib);
21242123
char errmsg[1024];
21252124
snprintf(errmsg,
21262125
sizeof(errmsg),
21272126
"Module version mismatch. Expected %d, got %d.",
21282127
NODE_MODULE_VERSION, mp->nm_version);
2128+
2129+
// NOTE: `mp` is allocated inside of the shared library's memory, calling
2130+
// `uv_dlclose` will deallocate it
2131+
uv_dlclose(&lib);
21292132
env->ThrowError(errmsg);
21302133
return;
21312134
}

0 commit comments

Comments
 (0)