Commit a41f0851 authored by Victor Stinner's avatar Victor Stinner

Issue #18408: pmerge() help of mro_implementation() now raises MemoryError on

memory allocation failure

Replace also PyMem_Free() with PyMem_FREE() to be consistent with the rest of
the function.
parent fb3a6300
...@@ -1456,8 +1456,10 @@ pmerge(PyObject *acc, PyObject* to_merge) { ...@@ -1456,8 +1456,10 @@ pmerge(PyObject *acc, PyObject* to_merge) {
that is not included in acc. that is not included in acc.
*/ */
remain = (int *)PyMem_MALLOC(SIZEOF_INT*to_merge_size); remain = (int *)PyMem_MALLOC(SIZEOF_INT*to_merge_size);
if (remain == NULL) if (remain == NULL) {
PyErr_NoMemory();
return -1; return -1;
}
for (i = 0; i < to_merge_size; i++) for (i = 0; i < to_merge_size; i++)
remain[i] = 0; remain[i] = 0;
...@@ -1489,7 +1491,7 @@ pmerge(PyObject *acc, PyObject* to_merge) { ...@@ -1489,7 +1491,7 @@ pmerge(PyObject *acc, PyObject* to_merge) {
} }
ok = PyList_Append(acc, candidate); ok = PyList_Append(acc, candidate);
if (ok < 0) { if (ok < 0) {
PyMem_Free(remain); PyMem_FREE(remain);
return -1; return -1;
} }
for (j = 0; j < to_merge_size; j++) { for (j = 0; j < to_merge_size; j++) {
......
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