Repository navigation
fix(SwathMapMassCorrection): remove leaked *new(SpectrumPtr) fallback - #9386
Conversation
The `*new(OpenSwath::SpectrumPtr)` fallback heap-allocated a default- constructed shared_ptr, dereferenced it, and never freed it — leaking one shared_ptr per empty-fetch fallback and producing a null pointer that downstream `integrateWindow` / `getDriftTimeArray()` would dereference (precondition violation in debug, crash in release). * correctMZ: skip the iteration via `continue` when fetchSpectrumSwath returns empty — mirrors the existing `used_maps.empty()` guard above. * correctIM: replace the fallback with `OpenSwath::SpectrumPtr()` and null-check sp_ms1 / sp_ms2 alongside the existing getDriftTimeArray() checks. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesSpectrum Null/Empty Safety Improvements
Possibly Related PRs
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
- FeatureFinderMetaboIdent: adduct support via optional TSV column (#9382) - BrukerTimsImagingFile: new Bruker .d MALDI imaging loader (#9383) - BrukerTimsFile: frame_id/RT range filter in Config (#9387) - Fix: SwathMapMassCorrection null-pointer and memory leak (#9386) Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
*new(OpenSwath::SpectrumPtr)inSwathMapMassCorrection.cppheap-allocated a default-constructedstd::shared_ptr<Spectrum>, dereferenced the raw pointer, copied the nullshared_ptr, and neverdeleted the heap object — a small leak per empty-fetch fallback in a per-peptide loop.shared_ptrthat the downstreamDIAHelpers::integrateWindow/sp->getDriftTimeArray()calls would dereference (precondition violation in debug, null deref in release). The fallback wasn't actually safe — it just deferred the crash.OpenSwath::SpectrumPtr()idiom — this PR brings the older sites in line.Changes
correctMZ: whenfetchSpectrumSwathreturns empty,continueto the next transition group — mirrors the existingused_maps.empty()guard a few lines above.correctIM: replace*new(OpenSwath::SpectrumPtr)with a default-constructedOpenSwath::SpectrumPtr()for bothsp_ms1andsp_ms2, and extend the two existinggetDriftTimeArray() == nullptrguards to also check for a nullshared_ptr.Test plan
cmake --build OpenMS-build --target SwathMapMassCorrection_test— builds cleanctest --test-dir OpenMS-build -R SwathMapMassCorrection_test— passes (0.40s)🤖 Generated with Claude Code
Summary by CodeRabbit