Skip to content

Commit d7f73c2

Browse files
committed
gh-142776: Ensure fp file descriptor is closed on all code paths in import.c
1 parent bef63d2 commit d7f73c2

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Python/import.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4822,7 +4822,7 @@ _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file)
48224822
mod = import_run_modexport(tstate, ex0, &info, spec);
48234823
// Modules created from slots handle GIL enablement (Py_mod_gil slot)
48244824
// when they're created.
4825-
goto cleanup;
4825+
goto finally;
48264826
}
48274827
if (p0 == NULL) {
48284828
goto finally;
@@ -4845,13 +4845,10 @@ _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file)
48454845
}
48464846
#endif
48474847

4848-
cleanup:
4849-
// XXX Shouldn't this happen in the error cases too (i.e. in "finally")?
4848+
finally:
48504849
if (fp) {
48514850
fclose(fp);
48524851
}
4853-
4854-
finally:
48554852
_Py_ext_module_loader_info_clear(&info);
48564853
return mod;
48574854
}

0 commit comments

Comments
 (0)