diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2011-08-14 01:25:39 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2011-08-15 20:08:18 +0200 |
commit | 5e37e10e41c269b12ede9126126032e3a1c57973 (patch) | |
tree | 77bf5d00ed07a63f66cde2b67aeb9d09d07be6e2 /src | |
parent | e8d268fd5fad5ac1356862a20b84cdd58bcb205c (diff) | |
download | nodejs-5e37e10e41c269b12ede9126126032e3a1c57973.tar.gz nodejs-5e37e10e41c269b12ede9126126032e3a1c57973.tar.bz2 nodejs-5e37e10e41c269b12ede9126126032e3a1c57973.zip |
module: fix pointer reference to out-of-scope variable
Reported by Tom Hughes.
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/node.cc b/src/node.cc index 527d11ca8..0ae59e81b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1574,6 +1574,7 @@ typedef void (*extInit)(Handle<Object> exports); // DLOpen is node.dlopen(). Used to load 'module.node' dynamically shared // objects. Handle<Value> DLOpen(const v8::Arguments& args) { + node_module_struct compat_mod; HandleScope scope; if (args.Length() < 2) return Undefined(); @@ -1616,10 +1617,13 @@ Handle<Value> DLOpen(const v8::Arguments& args) { // Get the init() function from the dynamically shared object. node_module_struct *mod = static_cast<node_module_struct *>(dlsym(handle, symstr)); free(symstr); + symstr = NULL; + // Error out if not found. if (mod == NULL) { /* Start Compatibility hack: Remove once everyone is using NODE_MODULE macro */ - node_module_struct compat_mod; + memset(&compat_mod, 0, sizeof compat_mod); + mod = &compat_mod; mod->version = NODE_MODULE_VERSION; |