Skip to content

Commit 1df2ec4

Browse files
committed
gh-151818: Fix double-free in _CALL_LIST_APPEND on allocation failure
_CALL_LIST_APPEND stole the arg stackref via PyStackRef_AsPyObjectSteal and passed it to _PyList_AppendTakeRef. When the list's backing array failed to grow, _PyList_AppendTakeRef decreffed the item, but the stale stackref remained on the value stack. The exception unwinder then closed it a second time, causing a double-free / use-after-free. Fix by giving _PyList_AppendTakeRef a separate reference via Py_NewRef and closing the stackref explicitly on success. On the error path the stackref still holds a valid reference, so the exception unwinder can safely close it.
1 parent a52f428 commit 1df2ec4

7 files changed

Lines changed: 942 additions & 1056 deletions

File tree

0 commit comments

Comments
 (0)