mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
Issue #18408: Fix PyDict_New() to handle correctly new_keys_object() failure
(MemoryError).
This commit is contained in:
parent
5d1866c78a
commit
c9b7f51ec2
1 changed files with 5 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue