Issue #11630, issue #3080: Fix refleak introduced by ef2b6305d395

This commit is contained in:
Victor Stinner 2011-03-22 10:46:35 +01:00
parent 0a4edd5435
commit e9ddbf65a8
1 changed files with 4 additions and 1 deletions

View File

@ -3705,12 +3705,15 @@ imp_load_dynamic(PyObject *self, PyObject *args)
return NULL;
if (fob != NULL) {
fp = get_file(NULL, fob, "r");
if (fp == NULL)
if (fp == NULL) {
Py_DECREF(pathname);
return NULL;
}
}
else
fp = NULL;
mod = _PyImport_LoadDynamicModule(name, pathname, fp);
Py_DECREF(pathname);
if (fp)
fclose(fp);
return mod;