[Python-Dev] [Python 2.4] PyInt_FromLong returning NULL
Tim Peters
tim.peters at gmail.com
Tue Dec 7 20:10:20 CET 2004
[Andreas Jung]
> Sorry, false alarm :-( There assignment of the NULL occurs in the
> if-clause of the corresponding code (I have overseen the ASSIGN
> call):
Thanks for the followup!
> if (! PyInt_Check(p))
> {
> if (PyDict_Check(p))
> {
> if (PyString_Check(name) ||
> PyUnicode_Check(name))
> {
> ASSIGN(p, PyObject_GetItem(p, name));
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> if (p == NULL) {
> puts("PyObject returned NULL");
> PyErr_Clear();
> }
> }
> else
> p = PyInt_FromLong((long)1);
>
> ...doing some further investigations on that.
I note that all of this is nested inside another "if (p) {...}" block.
That implies the "p = PyInt_FromLong((long)1);" line is at least a
memory leak: it overwrites p without decref'ing p first.
More information about the Python-Dev
mailing list