From 50abf2294ed5623e9b8025c5ed8e143f2f4af75c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 7 Nov 2013 23:56:10 +0100 Subject: [PATCH] Issue #19437: Fix fsconvert_strdup(), raise a MemoryError on PyMem_Malloc() failure --- Modules/posixmodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 789bf27bc4d..f282f998332 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;