bpo-36412: fix a possible crash in dictobject.c's new_dict() (GH-12519) · python/cpython@3d07c1e (original) (raw)
File tree
2 files changed
lines changed
- Misc/NEWS.d/next/Core and Builtins
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 | +Fix a possible crash when creating a new dictionary. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -604,7 +604,9 @@ new_dict(PyDictKeysObject *keys, PyObject **values) | ||
604 | 604 | mp = PyObject_GC_New(PyDictObject, &PyDict_Type); |
605 | 605 | if (mp == NULL) { |
606 | 606 | dictkeys_decref(keys); |
607 | -free_values(values); | |
607 | +if (values != empty_values) { | |
608 | +free_values(values); | |
609 | + } | |
608 | 610 | return NULL; |
609 | 611 | } |
610 | 612 | } |