The following patch ldo-structured-error-checks.patch.txt reworks some routines to fix holes in error checking and potential memory leaks from error recovery.
The basic principle is, all temporary object pointers are initialized to NULL at the start, and unconditionally passed to Py_XDECREF at end. Ownership of objects being constructed is only passed from temporary to result pointers after completion of all operations without errors. Note in particular how the loop-within-a-loop is handled in the Dir.getdents() routine.
The following patch ldo-structured-error-checks.patch.txt reworks some routines to fix holes in error checking and potential memory leaks from error recovery.
The basic principle is, all temporary object pointers are initialized to
NULL
at the start, and unconditionally passed toPy_XDECREF
at end. Ownership of objects being constructed is only passed from temporary to result pointers after completion of all operations without errors. Note in particular how the loop-within-a-loop is handled in theDir.getdents()
routine.