This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pakal
Recipients pakal, pitrou
Date 2010-01-15.21:21:27
SpamBayes Score 5.2631897e-08
Marked as misclassified No
Message-id <1263590489.29.0.622751301386.issue6939@psf.upfronthosting.co.za>
In-reply-to
Content
Allright, I shall fix all this asap.

But it seems the C code for truncate is actually buggy in the current 2.6 _fileio.c, around line 680.
CF code below :

posobj = portable_lseek(fd, posobj, 0); -> don't we lose the reference to the old "posobj" there, doing a memory leak ?

if (PyErr_Occurred()) return NULL; -> same thing, we return Null without caring about the posobj reference which should be non-Null there ??

If I've understood a little reference counting, "portable_lseek" returns a reference that we own and must Py_DECREF, isn't that so ?



--------
	if (posobj == Py_None || posobj == NULL) {
		/* Get the current position. */
                posobj = portable_lseek(fd, NULL, 1);
                if (posobj == NULL)
			return NULL;
        }
        else {
		/* Move to the position to be truncated. */
                posobj = portable_lseek(fd, posobj, 0);
        }

#if defined(HAVE_LARGEFILE_SUPPORT)
	pos = PyLong_AsLongLong(posobj);
#else
	pos = PyLong_AsLong(posobj);
#endif
	if (PyErr_Occurred())
		return NULL;

------
History
Date User Action Args
2010-01-15 21:21:29pakalsetrecipients: + pakal, pitrou
2010-01-15 21:21:29pakalsetmessageid: <1263590489.29.0.622751301386.issue6939@psf.upfronthosting.co.za>
2010-01-15 21:21:28pakallinkissue6939 messages
2010-01-15 21:21:27pakalcreate