Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 932af11

Browse files
committed
Patch #102868 from cgw: fix memory leak when an EOF is encountered
using GNU libc's getline()
1 parent 7292e92 commit 932af11

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Objects/fileobject.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,9 @@ get_line(PyFileObject *f, int n)
660660
n1 = getline(&buf, &size, fp);
661661
Py_END_ALLOW_THREADS
662662
if (n1 == -1) {
663+
if (buf){
664+
free(buf);
665+
}
663666
clearerr(fp);
664667
if (PyErr_CheckSignals()) {
665668
return NULL;

0 commit comments

Comments
 (0)