From cd4a3fd679a18e8ef243c6ad133ccda1bf74408a Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Tue, 15 Apr 2025 12:14:01 -0400 Subject: [PATCH] debugger: Skip out-of-bounds breakpoints when deserializing (#28781) Previously we'd crash when deserializing a breakpoint whose row number was out of bounds (could happen if the file was externally modified). This PR fixes that code to skip such breakpoints. An alternative would be to clip the deserialized `PointUtf16`, but I think that would mostly result in nonsensical breakpoints. Release Notes: - N/A --- crates/project/src/debugger/breakpoint_store.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/project/src/debugger/breakpoint_store.rs b/crates/project/src/debugger/breakpoint_store.rs index 33cc3d30a2..5cc361a73e 100644 --- a/crates/project/src/debugger/breakpoint_store.rs +++ b/crates/project/src/debugger/breakpoint_store.rs @@ -591,7 +591,13 @@ impl BreakpointStore { this.update(cx, |_, cx| BreakpointsInFile::new(buffer, cx))?; for bp in bps { - let position = snapshot.anchor_after(PointUtf16::new(bp.row, 0)); + let max_point = snapshot.max_point_utf16(); + let point = PointUtf16::new(bp.row, 0); + if point > max_point { + log::error!("skipping a deserialized breakpoint that's out of range"); + continue; + } + let position = snapshot.anchor_after(point); breakpoints_for_file.breakpoints.push(( position, Breakpoint {