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
This commit is contained in:
Cole Miller 2025-04-15 12:14:01 -04:00 committed by GitHub
parent 42c3f4e7cf
commit cd4a3fd679
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {