summaryrefslogtreecommitdiff
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2019-12-31 10:04:22 +0900
committerPablo Galindo <Pablogsal@gmail.com>2019-12-31 01:04:22 +0000
commit2d5bf568eaa5059402ccce9ba5a366986ba27c8a (patch)
tree04fe688caaa82e948cc4ff315fe82453f3445b6e /Objects/dictobject.c
parentee9ff05ec22ecd47dbffdd361967ccd55963dad2 (diff)
downloadcpython-git-2d5bf568eaa5059402ccce9ba5a366986ba27c8a.tar.gz
bpo-38588: Fix possible crashes in dict and list when calling PyObject_RichCompareBool (GH-17734)
Take strong references before calling PyObject_RichCompareBool to protect against the case where the object dies during the call.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 4afa19c8a0..87f88abbe5 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2777,9 +2777,11 @@ dict_equal(PyDictObject *a, PyDictObject *b)
return -1;
return 0;
}
+ Py_INCREF(bval);
cmp = PyObject_RichCompareBool(aval, bval, Py_EQ);
Py_DECREF(key);
Py_DECREF(aval);
+ Py_DECREF(bval);
if (cmp <= 0) /* error or not equal */
return cmp;
}