Fix multiple crashes related to incorrect rz_iterator usage. #3308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RzAnalysisBytes are owned by the iterator, so returning analysis bytes while destroying iterator owning it is incorrect.
Your checklist for this pull request
Detailed description
RzAnalysisBytes are owned by the iterator, so returning analysis bytes while destroying iterator owning it is incorrect. Previous version could cause use after free or attempts to free struct which shouldn't freed crashing either way.
Easiest methods to trigger the crash was opening right click context menu in disassembly or graph. And opening xrefs window on instruction with code xrefs (like the start of function). There might be others
getRzAnalysisBytesSingle
is indirectly used by quite a few places.I am not too happy about the RzIter wrapper. But since it's already there I was thinking I could replace some of the places currently dealing with RzAnalysisBytes to use RzAnalysisOp instead, but not in this pull request.
Seems like 8574f0b is also included in v2.3.3 so there is a high chance that it is mostly unusable due to right click crash.
Test plan (required)
Closing issues