diff options
| author | Thomas Heller <theller@ctypes.org> | 2008-07-15 19:39:38 +0000 |
|---|---|---|
| committer | Thomas Heller <theller@ctypes.org> | 2008-07-15 19:39:38 +0000 |
| commit | 880f529c04a5093e017bd41cf976ac62539a132c (patch) | |
| tree | 406c385357c53db89c939dea359c4c20731011a7 | |
| parent | 7103aa42c0d3ce8d75c9a9e299cf4d9b0be544de (diff) | |
| download | cpython-git-880f529c04a5093e017bd41cf976ac62539a132c.tar.gz | |
Issue #3313: Contrary to the man page, a failed dlopen() call does not
always set a dlerror() message.
| -rw-r--r-- | Misc/NEWS | 3 | ||||
| -rw-r--r-- | Modules/_ctypes/callproc.c | 5 | ||||
| -rw-r--r-- | Modules/dlmodule.c | 5 |
3 files changed, 11 insertions, 2 deletions
@@ -57,6 +57,9 @@ Core and Builtins 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 incomplete structure was created. diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index b16d7b071a..01ba8a00c2 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1410,8 +1410,11 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args) mode |= RTLD_NOW; handle = ctypes_dlopen(name, mode); if (!handle) { + char *errmsg = ctypes_dlerror(); + if (!errmsg) + errmsg = "dlopen() error"; PyErr_SetString(PyExc_OSError, - ctypes_dlerror()); + errmsg); return NULL; } return PyLong_FromVoidPtr(handle); diff --git a/Modules/dlmodule.c b/Modules/dlmodule.c index ccf1cb1835..b2ea4f5326 100644 --- a/Modules/dlmodule.c +++ b/Modules/dlmodule.c @@ -186,7 +186,10 @@ dl_open(PyObject *self, PyObject *args) } handle = dlopen(name, mode); if (handle == NULL) { - PyErr_SetString(Dlerror, dlerror()); + char *errmsg = dlerror(); + if (!errmsg) + errmsg = "dlopen() error"; + PyErr_SetString(Dlerror, errmsg); return NULL; } #ifdef __VMS |
