mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
Patch #102868 from cgw: fix memory leak when an EOF is encountered
using GNU libc's getline()
This commit is contained in:
parent
7292e921fc
commit
932af110d3
1 changed files with 3 additions and 0 deletions
|
@ -660,6 +660,9 @@ get_line(PyFileObject *f, int n)
|
||||||
n1 = getline(&buf, &size, fp);
|
n1 = getline(&buf, &size, fp);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
if (n1 == -1) {
|
if (n1 == -1) {
|
||||||
|
if (buf){
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
clearerr(fp);
|
clearerr(fp);
|
||||||
if (PyErr_CheckSignals()) {
|
if (PyErr_CheckSignals()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue