mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(codegen): source map builder panicked because it attempted to subtract with overflow in search_original_line_and_column (#8185)
See:
https://github.com/oxc-project/monitor-oxc/actions/runs/12531534720/job/34949348092
Related: #7926
This line causes panic.
46fc1a8b7d/crates/oxc_codegen/src/sourcemap_builder.rs (L147-L148)
After investigation, I found that the root cause was the code removed
in this PR. I don’t understand what the code was used for, but it was
obviously wrong. Because `idx` is always smaller than `cap`
This commit is contained in:
parent
56b7f133fa
commit
8ed976661a
1 changed files with 2 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{cmp::max, path::Path, sync::Arc};
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use nonmax::NonMaxU32;
|
||||
use oxc_index::{Idx, IndexVec};
|
||||
|
|
@ -235,9 +235,7 @@ impl SourcemapBuilder {
|
|||
let lines = &self.line_offset_tables.lines;
|
||||
let mut idx = self.last_line_lookup as usize;
|
||||
|
||||
let cap = idx.saturating_sub(16);
|
||||
idx = max(idx.saturating_sub(1), cap);
|
||||
while idx > cap && lines[idx].byte_offset_to_start_of_line > position {
|
||||
while lines[idx].byte_offset_to_start_of_line > position {
|
||||
idx -= 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue