diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-08-26 21:35:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 21:35:06 (GMT) |
commit | 2b15536fa94d07e9e286826c23507402313ec7f4 (patch) | |
tree | bed59616b5e2b833e15cc6b10f0dccfca8faa9fb /Modules/getpath.c | |
parent | e407cea1938b80b1d469f148a4ea65587820e3eb (diff) | |
download | cpython-2b15536fa94d07e9e286826c23507402313ec7f4.zip cpython-2b15536fa94d07e9e286826c23507402313ec7f4.tar.gz cpython-2b15536fa94d07e9e286826c23507402313ec7f4.tar.bz2 |
gh-107913: Fix possible losses of OSError error codes (GH-107930)
Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r-- | Modules/getpath.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index fb1656a..71e23e1 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -342,11 +342,12 @@ getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args) return NULL; } FILE *fp = _Py_wfopen(path, L"rb"); - PyMem_Free((void *)path); if (!fp) { PyErr_SetFromErrno(PyExc_OSError); + PyMem_Free((void *)path); return NULL; } + PyMem_Free((void *)path); r = PyList_New(0); if (!r) { |