Kaydet (Commit) 50abf229 authored tarafından Victor Stinner's avatar Victor Stinner

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

failure
üst 66b32709
...@@ -5053,8 +5053,10 @@ int fsconvert_strdup(PyObject *o, char**out) ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment