Fix #934: segfault when substituting a SubTree node#1083
Fix #934: segfault when substituting a SubTree node#1083facontidavide merged 2 commits intomasterfrom
Conversation
When a substitution rule replaced a SubTree with a TestNode, dynamic_cast<SubTreeNode*> returned nullptr but setSubtreeID was called unconditionally, causing a null pointer dereference. Add a null-check so setSubtreeID is only called on actual SubTree nodes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1083 +/- ##
==========================================
+ Coverage 65.90% 65.99% +0.09%
==========================================
Files 225 225
Lines 12727 12738 +11
Branches 1186 1186
==========================================
+ Hits 8388 8407 +19
+ Misses 4289 4281 -8
Partials 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Use explicit != nullptr comparisons for pointer-to-bool conversions flagged by clang-tidy. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
dynamic_cast<SubTreeNode*>inXMLParser::PImpl::recursivelyCreateTreebefore callingsetSubtreeIDSubTreeNode, so the cast returns nullptr causing a segfaultFixes #934
Test plan
Substitution.SubTreeNodeSubstitutiontest that reproduces the segfault by substituting a SubTree node🤖 Generated with Claude Code