mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Issue #19437: Fix fsconvert_strdup(), raise a MemoryError on PyMem_Malloc()
failure
This commit is contained in:
parent
66b3270975
commit
50abf2294e
1 changed files with 3 additions and 1 deletions
|
@ -5053,8 +5053,10 @@ int fsconvert_strdup(PyObject *o, char**out)
|
||||||
return 0;
|
return 0;
|
||||||
size = PyBytes_GET_SIZE(bytes);
|
size = PyBytes_GET_SIZE(bytes);
|
||||||
*out = PyMem_Malloc(size+1);
|
*out = PyMem_Malloc(size+1);
|
||||||
if (!*out)
|
if (!*out) {
|
||||||
|
PyErr_NoMemory();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
memcpy(*out, PyBytes_AsString(bytes), size+1);
|
memcpy(*out, PyBytes_AsString(bytes), size+1);
|
||||||
Py_DECREF(bytes);
|
Py_DECREF(bytes);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue