diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-12 17:11:13 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-12 17:11:13 (GMT) |
commit | 91a57216c95b84aa883816fcfacfdd6b91827113 (patch) | |
tree | 4dbf8f3ee59fb27971805e113c738b6b7789b579 | |
parent | 35c20969c810693c0339a7186c43b0d878fd5eae (diff) | |
download | cpython-91a57216c95b84aa883816fcfacfdd6b91827113.zip cpython-91a57216c95b84aa883816fcfacfdd6b91827113.tar.gz cpython-91a57216c95b84aa883816fcfacfdd6b91827113.tar.bz2 |
Fix memory leak in os.readlink
-rw-r--r-- | Modules/posixmodule.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8a78d8c..24c9e15 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5783,7 +5783,10 @@ posix_readlink(PyObject *self, PyObject *args) 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 @@ posix_readlink(PyObject *self, PyObject *args) 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) { |