Kaydet (Commit) 880f529c authored tarafından Thomas Heller's avatar Thomas Heller

Issue #3313: Contrary to the man page, a failed dlopen() call does not

always set a dlerror() message.
üst 7103aa42
...@@ -57,6 +57,9 @@ Core and Builtins ...@@ -57,6 +57,9 @@ Core and Builtins
Library Library
------- -------
- Issue #3313: Fixed a crash when a failed dlopen() call does not set
a valid dlerror() message.
- Issue #3258: Fixed a crash when a ctypes POINTER type to an - Issue #3258: Fixed a crash when a ctypes POINTER type to an
incomplete structure was created. incomplete structure was created.
......
...@@ -1410,8 +1410,11 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args) ...@@ -1410,8 +1410,11 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
mode |= RTLD_NOW; mode |= RTLD_NOW;
handle = ctypes_dlopen(name, mode); handle = ctypes_dlopen(name, mode);
if (!handle) { if (!handle) {
char *errmsg = ctypes_dlerror();
if (!errmsg)
errmsg = "dlopen() error";
PyErr_SetString(PyExc_OSError, PyErr_SetString(PyExc_OSError,
ctypes_dlerror()); errmsg);
return NULL; return NULL;
} }
return PyLong_FromVoidPtr(handle); return PyLong_FromVoidPtr(handle);
......
...@@ -186,7 +186,10 @@ dl_open(PyObject *self, PyObject *args) ...@@ -186,7 +186,10 @@ dl_open(PyObject *self, PyObject *args)
} }
handle = dlopen(name, mode); handle = dlopen(name, mode);
if (handle == NULL) { if (handle == NULL) {
PyErr_SetString(Dlerror, dlerror()); char *errmsg = dlerror();
if (!errmsg)
errmsg = "dlopen() error";
PyErr_SetString(Dlerror, errmsg);
return NULL; return NULL;
} }
#ifdef __VMS #ifdef __VMS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment