- SF Bug #1350188, "setdlopenflags" leads to crash upon "import"
It was possible dlerror() returns a NULL pointer, use a default error
message in this case.
diff --git a/Misc/NEWS b/Misc/NEWS
index 5191c25..b257e0e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@
Core and builtins
-----------------
+- SF Bug #1350188, "setdlopenflags" leads to crash upon "import"
+ It was possible dlerror() returns a NULL pointer, use a default error
+ message in this case.
+
- Replaced most Unicode charmap codecs with new ones using the
new Unicode translate string feature in the builtin charmap
codec; the codecs were created from the mapping tables available
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c
index 2b5a11a..960e5c0 100644
--- a/Python/dynload_shlib.c
+++ b/Python/dynload_shlib.c
@@ -130,7 +130,10 @@
handle = dlopen(pathname, dlopenflags);
if (handle == NULL) {
- PyErr_SetString(PyExc_ImportError, dlerror());
+ char *error = dlerror();
+ if (error == NULL)
+ error = "unknown dlopen() error";
+ PyErr_SetString(PyExc_ImportError, error);
return NULL;
}
if (fp != NULL && nhandles < 128)