[Python-checkins] r64976 - in python/trunk: Misc/NEWS Modules/_ctypes/callproc.c Modules/dlmodule.c

thomas.heller python-checkins at python.org
Tue Jul 15 21:39:38 CEST 2008


Author: thomas.heller
Date: Tue Jul 15 21:39:38 2008
New Revision: 64976

Log:
Issue #3313: Contrary to the man page, a failed dlopen() call does not
always set a dlerror() message.


Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/_ctypes/callproc.c
   python/trunk/Modules/dlmodule.c

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Jul 15 21:39:38 2008
@@ -57,6 +57,9 @@
 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.
 

Modified: python/trunk/Modules/_ctypes/callproc.c
==============================================================================
--- python/trunk/Modules/_ctypes/callproc.c	(original)
+++ python/trunk/Modules/_ctypes/callproc.c	Tue Jul 15 21:39:38 2008
@@ -1410,8 +1410,11 @@
 	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);

Modified: python/trunk/Modules/dlmodule.c
==============================================================================
--- python/trunk/Modules/dlmodule.c	(original)
+++ python/trunk/Modules/dlmodule.c	Tue Jul 15 21:39:38 2008
@@ -186,7 +186,10 @@
 	}
 	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


More information about the Python-checkins mailing list