Ensure path is initialized to prevent freeing random memory

(reported by Thomas Heller).  If have_unicode_filename is set,
path looks like it will not be used, so there's no need to free it.
This commit is contained in:
Neal Norwitz 2004-06-09 01:46:02 +00:00
parent 4182cfd7db
commit 2adf210993
1 changed files with 2 additions and 4 deletions

View File

@ -1994,7 +1994,7 @@ second form is used, set the access and modified times to the current time.");
static PyObject * static PyObject *
posix_utime(PyObject *self, PyObject *args) posix_utime(PyObject *self, PyObject *args)
{ {
char *path; char *path = NULL;
long atime, mtime, ausec, musec; long atime, mtime, ausec, musec;
int res; int res;
PyObject* arg; PyObject* arg;
@ -2087,10 +2087,8 @@ posix_utime(PyObject *self, PyObject *args)
} }
if (res < 0) { if (res < 0) {
#ifdef Py_WIN_WIDE_FILENAMES #ifdef Py_WIN_WIDE_FILENAMES
if (have_unicode_filename) { if (have_unicode_filename)
PyMem_Free(path);
return posix_error_with_unicode_filename(wpath); return posix_error_with_unicode_filename(wpath);
}
#endif /* Py_WIN_WIDE_FILENAMES */ #endif /* Py_WIN_WIDE_FILENAMES */
return posix_error_with_allocated_filename(path); return posix_error_with_allocated_filename(path);
} }