Message258708
Expected behavior:
Calling Py_BuildValue with a 'N' argument should take ownership of the N object, and on failure (returns NULL), call Py_DECREF() on any N argument. The documentation explicitly says that this is the intended usage:
"N": Same as "O", except it doesn't increment the reference count on the object. Useful when the object is created by a call to an object constructor in the argument list.
Actual behavior:
N objects appear to be abandoned/leaked in some cases.
Example: PyBuildValue("iN", 0, obj);
* calls _Py_BuildValue_SizeT via macro
* calls va_build_value (in modsupport.c)
* calls do_mktuple [0]
* [0] first calls v = PyTuple_New(n=2). If this fails, it returns NULL, leaking obj.
* if [0] creates the tuple v, then it goes on to populate the values in the tuple.
* [0] calls do_mkvalue() to create the "i=0" object. If this fails, obj is never Py_DECREF()'ed.
Many other leaks are possible, as long as at least one allocation occurs prior to the processing of the N arguments. |
|
Date |
User |
Action |
Args |
2016-01-20 18:26:25 | squidevil | set | recipients:
+ squidevil |
2016-01-20 18:26:25 | squidevil | set | messageid: <1453314385.46.0.703497250236.issue26168@psf.upfronthosting.co.za> |
2016-01-20 18:26:25 | squidevil | link | issue26168 messages |
2016-01-20 18:26:25 | squidevil | create | |
|