[issue8420] Objects/setobject.c contains unsafe code

Raymond Hettinger report at bugs.python.org
Sun Apr 18 20:21:41 CEST 2010


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

>Bugs in set_repr:
>> keys = PySequence_List((PyObject *)so);
>> if (keys == NULL)
>> 	goto done;
>> 
>> listrepr = PyObject_Repr(keys);
>> Py_DECREF(keys);
>List pointed to by keys is already deallocated at this point.
>> if (listrepr == NULL) {
>> 	Py_DECREF(keys);
>>But this code tries to DECREF it.
>> 	goto done;
>> }

I don't follow why you think keys is already deallocated.
When assigned by PySequence_List() without a NULL return, the refcnt is one. The call to PyObject_Repr(keys) does not change the refcnt of keys,
so the Py_DECREF(keys) is correct.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8420>
_______________________________________


More information about the Python-bugs-list mailing list