Commit c9b7f51e authored by Victor Stinner's avatar Victor Stinner

Issue #18408: Fix PyDict_New() to handle correctly new_keys_object() failure

(MemoryError).
parent 5d1866c7
......@@ -389,6 +389,7 @@ static PyObject *
new_dict(PyDictKeysObject *keys, PyObject **values)
{
PyDictObject *mp;
assert(keys != NULL);
if (numfree) {
mp = free_list[--numfree];
assert (mp != NULL);
......@@ -431,7 +432,10 @@ new_dict_with_shared_keys(PyDictKeysObject *keys)
PyObject *
PyDict_New(void)
{
return new_dict(new_keys_object(PyDict_MINSIZE_COMBINED), NULL);
PyDictKeysObject *keys = new_keys_object(PyDict_MINSIZE_COMBINED);
if (keys == NULL)
return NULL;
return new_dict(keys, NULL);
}
/*
......
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