Commit 060b6b25 authored by Neal Norwitz's avatar Neal Norwitz

Fix memory leak in os.readlink

parent ff676c15
...@@ -5783,7 +5783,10 @@ posix_readlink(PyObject *self, PyObject *args) ...@@ -5783,7 +5783,10 @@ posix_readlink(PyObject *self, PyObject *args)
return NULL; return NULL;
#ifdef Py_USING_UNICODE #ifdef Py_USING_UNICODE
v = PySequence_GetItem(args, 0); v = PySequence_GetItem(args, 0);
if (v == NULL) return NULL; if (v == NULL) {
PyMem_Free(path);
return NULL;
}
if (PyUnicode_Check(v)) { if (PyUnicode_Check(v)) {
arg_is_unicode = 1; arg_is_unicode = 1;
...@@ -5795,8 +5798,9 @@ posix_readlink(PyObject *self, PyObject *args) ...@@ -5795,8 +5798,9 @@ posix_readlink(PyObject *self, PyObject *args)
n = readlink(path, buf, (int) sizeof buf); n = readlink(path, buf, (int) sizeof buf);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (n < 0) if (n < 0)
return posix_error_with_filename(path); return posix_error_with_allocated_filename(path);
PyMem_Free(path);
v = PyString_FromStringAndSize(buf, n); v = PyString_FromStringAndSize(buf, n);
#ifdef Py_USING_UNICODE #ifdef Py_USING_UNICODE
if (arg_is_unicode) { if (arg_is_unicode) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment