[Python-checkins] r56960 - python/trunk/Modules/posixmodule.c
neal.norwitz
python-checkins at python.org
Sun Aug 12 19:11:13 CEST 2007
Author: neal.norwitz
Date: Sun Aug 12 19:11:13 2007
New Revision: 56960
Modified:
python/trunk/Modules/posixmodule.c
Log:
Fix memory leak in os.readlink
Modified: python/trunk/Modules/posixmodule.c
==============================================================================
--- python/trunk/Modules/posixmodule.c (original)
+++ python/trunk/Modules/posixmodule.c Sun Aug 12 19:11:13 2007
@@ -5783,7 +5783,10 @@
return NULL;
#ifdef Py_USING_UNICODE
v = PySequence_GetItem(args, 0);
- if (v == NULL) return NULL;
+ if (v == NULL) {
+ PyMem_Free(path);
+ return NULL;
+ }
if (PyUnicode_Check(v)) {
arg_is_unicode = 1;
@@ -5795,8 +5798,9 @@
n = readlink(path, buf, (int) sizeof buf);
Py_END_ALLOW_THREADS
if (n < 0)
- return posix_error_with_filename(path);
+ return posix_error_with_allocated_filename(path);
+ PyMem_Free(path);
v = PyString_FromStringAndSize(buf, n);
#ifdef Py_USING_UNICODE
if (arg_is_unicode) {
More information about the Python-checkins
mailing list