Fix use-after-free in UndoableTransaction::unwind - #34760
Conversation
…t being freed before the Link command is undone
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: ⚪ Minimal · up to The rollback path now keeps commands alive until all undo operations finish, preventing the cancellation crash caused by premature cleanup. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Resolves: #34717
The issue reported a crash when clicking "cancel" from the instrument change dialog inside a part. This happened because:
EngravingItem::linkedClone()adds aLinkcommand before the linked clone'sAddElementUndoableTransaction::unwind()rolled back the cancelled transaction one command at a time, undoing and freeing each.unwindfreed theAddElementand its items, and the~EngravingObjectdestructor freed theLinkedObjectslist pointer once it was empty.Link::undo()was called, it calledunlink()on the freed object and on aLinkedObjectslist its destructor had already deleted.unwind()now undoes every command first and only frees them once all the undos are done.