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;