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; return NULL;
if (fob != NULL) { if (fob != NULL) {
fp = get_file(NULL, fob, "r"); fp = get_file(NULL, fob, "r");
if (fp == NULL) if (fp == NULL) {
Py_DECREF(pathname);
return NULL; return NULL;
}
} }
else else
fp = NULL; fp = NULL;
mod = _PyImport_LoadDynamicModule(name, pathname, fp); mod = _PyImport_LoadDynamicModule(name, pathname, fp);
Py_DECREF(pathname);
if (fp) if (fp)
fclose(fp); fclose(fp);
return mod; return mod;