diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-08-26 23:24:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 23:24:40 (GMT) |
commit | 3e2030371723e5fb7c9ccbe83cd980ce69cabc1a (patch) | |
tree | 16a5ba8999b1440a494153cd76e5a71a779ebb28 /Modules/_multiprocessing | |
parent | bbdd8895a5aced4cd4e66a5c6e3471636f28df6b (diff) | |
download | cpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.zip cpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.tar.gz cpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.tar.bz2 |
[3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) (#108523)
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.
(cherry picked from commit 2b15536fa94d07e9e286826c23507402313ec7f4)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/_multiprocessing')
-rw-r--r-- | Modules/_multiprocessing/semaphore.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c index 897b8db..c7df82d 100644 --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -516,12 +516,12 @@ _multiprocessing_SemLock_impl(PyTypeObject *type, int kind, int value, return result; failure: - if (handle != SEM_FAILED) - SEM_CLOSE(handle); - PyMem_Free(name_copy); if (!PyErr_Occurred()) { _PyMp_SetError(NULL, MP_STANDARD_ERROR); } + if (handle != SEM_FAILED) + SEM_CLOSE(handle); + PyMem_Free(name_copy); return NULL; } @@ -556,8 +556,9 @@ _multiprocessing_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle, if (name != NULL) { handle = sem_open(name, 0); if (handle == SEM_FAILED) { + PyErr_SetFromErrno(PyExc_OSError); PyMem_Free(name_copy); - return PyErr_SetFromErrno(PyExc_OSError); + return NULL; } } #endif |