summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2000-12-19 20:59:04 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2000-12-19 20:59:04 (GMT)
commit932af110d36932d940eaa01d1a3759f0347a59fd (patch)
tree4bff6ba41fac5b54fc1ebf63b728f10a164ecce6 /Objects/fileobject.c
parent7292e921fc9b0128a2224eb4cd45c2649211c9cf (diff)
downloadcpython-932af110d36932d940eaa01d1a3759f0347a59fd.zip
cpython-932af110d36932d940eaa01d1a3759f0347a59fd.tar.gz
cpython-932af110d36932d940eaa01d1a3759f0347a59fd.tar.bz2
Patch #102868 from cgw: fix memory leak when an EOF is encountered
using GNU libc's getline()
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 43b81ed..96d3830 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -660,6 +660,9 @@ get_line(PyFileObject *f, int n)
n1 = getline(&buf, &size, fp);
Py_END_ALLOW_THREADS
if (n1 == -1) {
+ if (buf){
+ free(buf);
+ }
clearerr(fp);
if (PyErr_CheckSignals()) {
return NULL;