summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-07 22:56:10 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-07 22:56:10 (GMT)
commit50abf2294ed5623e9b8025c5ed8e143f2f4af75c (patch)
tree31b40de5e065e3fafe7b06b6490165062e29caea /Modules/posixmodule.c
parent66b3270975ebf33596559d70549ea66d1dfd9d9c (diff)
downloadcpython-50abf2294ed5623e9b8025c5ed8e143f2f4af75c.zip
cpython-50abf2294ed5623e9b8025c5ed8e143f2f4af75c.tar.gz
cpython-50abf2294ed5623e9b8025c5ed8e143f2f4af75c.tar.bz2
Issue #19437: Fix fsconvert_strdup(), raise a MemoryError on PyMem_Malloc()
failure
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 789bf27b..f282f99 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5053,8 +5053,10 @@ int fsconvert_strdup(PyObject *o, char**out)
return 0;
size = PyBytes_GET_SIZE(bytes);
*out = PyMem_Malloc(size+1);
- if (!*out)
+ if (!*out) {
+ PyErr_NoMemory();
return 0;
+ }
memcpy(*out, PyBytes_AsString(bytes), size+1);
Py_DECREF(bytes);
return 1;