[Python-checkins] python/dist/src/Modules posixmodule.c, 2.318,
2.319
nnorwitz at users.sourceforge.net
nnorwitz at users.sourceforge.net
Sun Jun 6 16:40:30 EDT 2004
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16270/Modules
Modified Files:
posixmodule.c
Log Message:
Plug a few memory leaks in utime(). path is allocated from within
PyArg_ParseTuple() since the format is "et" This change should
be reviewed carefully.
Bugfix candidate.
Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.318
retrieving revision 2.319
diff -C2 -d -r2.318 -r2.319
*** posixmodule.c 2 Jun 2004 09:57:56 -0000 2.318
--- posixmodule.c 6 Jun 2004 20:40:27 -0000 2.319
***************
*** 2050,2062 ****
PyErr_SetString(PyExc_TypeError,
"utime() arg 2 must be a tuple (atime, mtime)");
return NULL;
}
else {
if (extract_time(PyTuple_GET_ITEM(arg, 0),
! &atime, &ausec) == -1)
return NULL;
if (extract_time(PyTuple_GET_ITEM(arg, 1),
! &mtime, &musec) == -1)
return NULL;
ATIME = atime;
MTIME = mtime;
--- 2050,2067 ----
PyErr_SetString(PyExc_TypeError,
"utime() arg 2 must be a tuple (atime, mtime)");
+ PyMem_Free(path);
return NULL;
}
else {
if (extract_time(PyTuple_GET_ITEM(arg, 0),
! &atime, &ausec) == -1) {
! PyMem_Free(path);
return NULL;
+ }
if (extract_time(PyTuple_GET_ITEM(arg, 1),
! &mtime, &musec) == -1) {
! PyMem_Free(path);
return NULL;
+ }
ATIME = atime;
MTIME = mtime;
***************
*** 2083,2091 ****
if (res < 0) {
#ifdef Py_WIN_WIDE_FILENAMES
! if (have_unicode_filename)
return posix_error_with_unicode_filename(wpath);
#endif /* Py_WIN_WIDE_FILENAMES */
! return posix_error_with_filename(path);
}
Py_INCREF(Py_None);
return Py_None;
--- 2088,2099 ----
if (res < 0) {
#ifdef Py_WIN_WIDE_FILENAMES
! if (have_unicode_filename) {
! PyMem_Free(path);
return posix_error_with_unicode_filename(wpath);
+ }
#endif /* Py_WIN_WIDE_FILENAMES */
! return posix_error_with_allocated_filename(path);
}
+ PyMem_Free(path);
Py_INCREF(Py_None);
return Py_None;
More information about the Python-checkins
mailing list