Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb90946

Browse files
committed
Some robustness checks in Py_ReprLeave() in the unlikely event someone
has messed with the dictionary or list.
1 parent 8f6b958 commit eb90946

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Objects/object.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,11 @@ Py_ReprLeave(obj)
844844
int i;
845845

846846
dict = PyThreadState_GetDict();
847+
if (dict == NULL)
848+
return;
847849
list = PyDict_GetItemString(dict, KEY);
850+
if (list == NULL || !PyList_Check(list))
851+
return;
848852
i = PyList_GET_SIZE(list);
849853
/* Count backwards because we always expect obj to be list[-1] */
850854
while (--i >= 0) {

0 commit comments

Comments
 (0)