From: Neal Norwitz Date: Wed, 9 Nov 2005 07:02:40 +0000 (+0000) Subject: Backport: X-Git-Tag: v2.4.3c1~220 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=757dab9df72ffb0850b01710ad58d5898aed422d;p=thirdparty%2FPython%2Fcpython.git Backport: 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 ba21bfd435b9..8bc7a81ec714 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,10 @@ What's New in Python 2.4.3c1? 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. + - SF bug #1167751: fix incorrect code being for generator expressions. The following code now raises a SyntaxError: foo(a = i for i in range(10)) diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 2b5a11a220ee..960e5c093378 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -130,7 +130,10 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, 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)