summaryrefslogtreecommitdiff
path: root/Modules/_multiprocessing
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-12-07 03:11:30 -0700
committerSerhiy Storchaka <storchaka@gmail.com>2018-12-07 12:11:30 +0200
commit4c49da0cb7434c676d70b9ccf38aca82ac0d64a9 (patch)
treeaae3660f9a5bc462830107cf2311b2557898e268 /Modules/_multiprocessing
parent3a521f0b6167628f975c773b56c7daf8d33d6f40 (diff)
downloadcpython-git-4c49da0cb7434c676d70b9ccf38aca82ac0d64a9.tar.gz
bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015)
Set MemoryError when appropriate, add missing failure checks, and fix some potential leaks.
Diffstat (limited to 'Modules/_multiprocessing')
-rw-r--r--Modules/_multiprocessing/semaphore.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c
index e15adfbd6b..bb7219e130 100644
--- a/Modules/_multiprocessing/semaphore.c
+++ b/Modules/_multiprocessing/semaphore.c
@@ -449,8 +449,9 @@ semlock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!unlink) {
name_copy = PyMem_Malloc(strlen(name) + 1);
- if (name_copy == NULL)
- goto failure;
+ if (name_copy == NULL) {
+ return PyErr_NoMemory();
+ }
strcpy(name_copy, name);
}
@@ -473,7 +474,9 @@ semlock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (handle != SEM_FAILED)
SEM_CLOSE(handle);
PyMem_Free(name_copy);
- _PyMp_SetError(NULL, MP_STANDARD_ERROR);
+ if (!PyErr_Occurred()) {
+ _PyMp_SetError(NULL, MP_STANDARD_ERROR);
+ }
return NULL;
}