summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2004-06-06 20:40:27 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2004-06-06 20:40:27 (GMT)
commit9665271f92a5aa7fcd02eda4b6e67f2b23941cb3 (patch)
treecfeee288503263c423627677b535d945328dd218 /Modules/posixmodule.c
parentc28e7ad3d0ae7bab7be11c57f49c0cafa31e82a5 (diff)
downloadcpython-9665271f92a5aa7fcd02eda4b6e67f2b23941cb3.zip
cpython-9665271f92a5aa7fcd02eda4b6e67f2b23941cb3.tar.gz
cpython-9665271f92a5aa7fcd02eda4b6e67f2b23941cb3.tar.bz2
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.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 42bc767..599d88a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2049,15 +2049,20 @@ posix_utime(PyObject *self, PyObject *args)
else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) {
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)
+ &atime, &ausec) == -1) {
+ PyMem_Free(path);
return NULL;
+ }
if (extract_time(PyTuple_GET_ITEM(arg, 1),
- &mtime, &musec) == -1)
+ &mtime, &musec) == -1) {
+ PyMem_Free(path);
return NULL;
+ }
ATIME = atime;
MTIME = mtime;
#ifdef HAVE_UTIMES
@@ -2082,11 +2087,14 @@ posix_utime(PyObject *self, PyObject *args)
}
if (res < 0) {
#ifdef Py_WIN_WIDE_FILENAMES
- if (have_unicode_filename)
+ if (have_unicode_filename) {
+ PyMem_Free(path);
return posix_error_with_unicode_filename(wpath);
+ }
#endif /* Py_WIN_WIDE_FILENAMES */
- return posix_error_with_filename(path);
+ return posix_error_with_allocated_filename(path);
}
+ PyMem_Free(path);
Py_INCREF(Py_None);
return Py_None;
#undef UTIME_ARG