fix: null array indexing in CTracer_handle_return by frigus02 · Pull Request #1843 · nedbat/coveragepy (original) (raw)
Fixes #1835
CTracer_set_pdata_stack
can initialize self.pdata_stack
to an empty stack where ->stack
is NULL
and ->deph
is -1.
Move index into ->stack
into ->depth>=0
check to avoid indexing into NULL
array.
This issue was found running UndefinedBehaviourSanitizer. It's reproducible in regular test runs, e.g. python3 -m tox -e py311
. Adding if (self->pdata_stack->stack == NULL) { fprint(...) }
before the moved line shows the issue in several test cases.
The contributing guide mentions ever fix should include tests. I'd be happy to add some, but I'm not quite sure how to do that here. Do you have a preference/advice?