summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-08 20:19:20 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-08 20:19:20 (GMT)
commitc9b7f51ec203ea5148014741d1fefe1a0faeefa1 (patch)
treec6ef51aa76de8671b16a4d0303f0da37cd228203 /Objects/dictobject.c
parent5d1866c78a4caf9825a0ce90863c19f65279da86 (diff)
downloadcpython-c9b7f51ec203ea5148014741d1fefe1a0faeefa1.zip
cpython-c9b7f51ec203ea5148014741d1fefe1a0faeefa1.tar.gz
cpython-c9b7f51ec203ea5148014741d1fefe1a0faeefa1.tar.bz2
Issue #18408: Fix PyDict_New() to handle correctly new_keys_object() failure
(MemoryError).
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 250c890..9d8696a 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -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);
}
/*