Index: Python/import.c =================================================================== --- Python/import.c (revision 64979) +++ Python/import.c (working copy) @@ -3168,6 +3168,7 @@ pathlen = strlen(path); if (pathlen == 0) { + PyMem_Free(path); PyErr_SetString(PyExc_ImportError, "empty pathname"); return -1; } else { @@ -3189,6 +3190,7 @@ rv = stat(mangled, &statbuf); } #endif + PyMem_Free(path); if (rv == 0) { /* it exists */ if (S_ISDIR(statbuf.st_mode)) {