mirror of https://github.com/python/cpython
Issue #19437: Fix fsconvert_strdup(), raise a MemoryError on PyMem_Malloc()
failure
This commit is contained in:
parent
66b3270975
commit
50abf2294e
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue