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

Skip to content

Commit c80baa3

Browse files
committed
err_input(): Nailed a small memory leak. If the error is E_INTR, the
v temporary variable was never decref'd. Test this by starting up the interpreter, hitting C-c, then immediately exiting. Same potential leak can occur if error is E_NOMEM, since the return is done in the case block. Added Py_XDECREF(v); to both blocks, just before the return.
1 parent 54892c4 commit c80baa3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Python/pythonrun.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,13 +992,14 @@ err_input(err)
992992
break;
993993
case E_TOKEN:
994994
msg = "invalid token";
995-
996995
break;
997996
case E_INTR:
998997
PyErr_SetNone(PyExc_KeyboardInterrupt);
998+
Py_XDECREF(v);
999999
return;
10001000
case E_NOMEM:
10011001
PyErr_NoMemory();
1002+
Py_XDECREF(v);
10021003
return;
10031004
case E_EOF:
10041005
msg = "unexpected EOF while parsing";

0 commit comments

Comments
 (0)