Issue #19437: Fix fsconvert_strdup(), raise a MemoryError on PyMem_Malloc()

failure
This commit is contained in:
Victor Stinner 2013-11-07 23:56:10 +01:00
parent 66b3270975
commit 50abf2294e
1 changed files with 3 additions and 1 deletions

View File

@ -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;