diff Python/dynload_win.c @ 73650:071cc767a28e

Check for PyUnicode_AS_UNICODE() failure
author Victor Stinner <victor.stinner@haypocalc.com>
date Mon, 21 Nov 2011 02:01:41 +0100
parents 8d29cdf28216
children d48b4a1c511a
line wrap: on
line diff
--- a/Python/dynload_win.c	Mon Nov 21 01:17:27 2011 +0100
+++ b/Python/dynload_win.c	Mon Nov 21 02:01:41 2011 +0100
@@ -176,11 +176,16 @@
 {
     dl_funcptr p;
     char funcname[258], *import_python;
+    wchar_t *wpathname;
 
 #ifndef _DEBUG
     _Py_CheckPython3();
 #endif
 
+    wpathname = PyUnicode_AsUnicode(pathname);
+    if (wpathname == NULL)
+        return NULL;
+
     PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname);
 
     {
@@ -195,7 +200,7 @@
         /* We use LoadLibraryEx so Windows looks for dependent DLLs
             in directory of pathname first. */
         /* XXX This call doesn't exist in Windows CE */
-        hDLL = LoadLibraryExW(PyUnicode_AS_UNICODE(pathname), NULL,
+        hDLL = LoadLibraryExW(wpathname, NULL,
                               LOAD_WITH_ALTERED_SEARCH_PATH);
         _Py_DeactivateActCtx(cookie);