From: Fedor Indutny Date: Thu, 10 Sep 2015 11:01:20 +0000 (-0700) Subject: bindings: close after reading module struct X-Git-Tag: v4.1.0~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9683e5df51956e737eb5a2914458d481e2dc4bd8;p=platform%2Fupstream%2Fnodejs.git 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 Reviewed-By: Brian White Reviewed-By: Yosuke Furukawa --- diff --git a/src/node.cc b/src/node.cc index 74274f7..d48fd2a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2087,12 +2087,15 @@ void DLOpen(const FunctionCallbackInfo& 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; }