gh-118331: Fix a couple of issues when list allocation fails by mpage · Pull Request #130811 · python/cpython
Set the items pointer in the list object to NULL after the items array is freed during list deallocation. Otherwise, we can end up with a list object added to the free list that contains a pointer to an already-freed items array.
Bot
mentioned this pull request
I think technically it's not escaping, because the only object that can be decrefed if allocation fails is an exact list, which cannot execute arbitrary code when it is destroyed. However, this seems less intrusive than trying to special cases objects in the assert in `_Py_Dealloc` that checks for non-null stackpointers and shouldn't matter for performance.
mpage
changed the title
gh-118331: Fix use after free in list objects
gh-118331: Fix a couple of issues when list allocation fails
mpage
marked this pull request as ready for review
mpage
mentioned this pull request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters