Skip to content

Commit

Permalink
module: fix pointer reference to out-of-scope variable
Browse files Browse the repository at this point in the history
Reported by Tom Hughes.
  • Loading branch information
bnoordhuis committed Aug 15, 2011
1 parent e8d268f commit 5e37e10
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node.cc
Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 5e37e10

Please sign in to comment.