]> granicus.if.org Git - python/commitdiff
Some robustness checks in Py_ReprLeave() in the unlikely event someone
authorGuido van Rossum <guido@python.org>
Sat, 11 Apr 1998 15:17:34 +0000 (15:17 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 11 Apr 1998 15:17:34 +0000 (15:17 +0000)
has messed with the dictionary or list.

Objects/object.c

index f84e64fa2c3e30d66c416665a460f573e22b65be..1a1ed52208c7ebdac25b75b999622a2d1aea2f4f 100644 (file)
@@ -844,7 +844,11 @@ Py_ReprLeave(obj)
        int i;
 
        dict = PyThreadState_GetDict();
+       if (dict == NULL)
+               return;
        list = PyDict_GetItemString(dict, KEY);
+       if (list == NULL || !PyList_Check(list))
+               return;
        i = PyList_GET_SIZE(list);
        /* Count backwards because we always expect obj to be list[-1] */
        while (--i >= 0) {