about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/module.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ff7c100f8..5939ea141 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
 	* 34382: Src/module.c: Handle NULL return from dlerror() more
 	gracefully
 
+	* 34387: Src/module.c: Avoid loading the main zsh binary as
+	a module
+
 2015-01-26  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 34402: Src/Modules/db_gdbm.c: make unsetting a tied gdbm
diff --git a/Src/module.c b/Src/module.c
index 97a4869cd..7dd47016c 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -1577,7 +1577,9 @@ try_load_module(char const *name)
 	if (l + (**pp ? strlen(*pp) : 1) > PATH_MAX)
 	    continue;
 	sprintf(buf, "%s/%s.%s", **pp ? *pp : ".", name, DL_EXT);
-	ret = dlopen(unmeta(buf), RTLD_LAZY | RTLD_GLOBAL);
+	unmetafy(buf, NULL);
+	if (*buf) /* dlopen(NULL) returns a handle to the main binary */
+	    ret = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
     }
 
     return ret;