Skip to content

Commit 12889da

Browse files
Benoit Aubuchonclaude
andcommitted
fix: use saturating_sub and remove redundant trim_end in infra_reality_checker
Prevent potential debug-mode panic from usize underflow in the column block depth walker by switching bare `depth -= 1` to `depth.saturating_sub(1)`, matching the pattern already used in `find_top_level_keyword`. Also remove the redundant `trim_end()` call before `split_whitespace()` flagged by Clippy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7d83345 commit 12889da

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

apps/framework-cli/src/framework/core/infra_reality_checker.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,7 @@ fn fill_hidden_credentials(actual: &str, desired: &str) -> String {
146146
let abs = offset + pos;
147147
// Find the keyword immediately before '[HIDDEN]' (last whitespace-delimited
148148
// token before the opening quote).
149-
let kw = result[..abs]
150-
.trim_end()
151-
.split_whitespace()
152-
.next_back()
153-
.unwrap_or("");
149+
let kw = result[..abs].split_whitespace().next_back().unwrap_or("");
154150
if !kw.is_empty() {
155151
// Find `KEYWORD 'value'` in desired and extract the value.
156152
let search = format!("{} '", kw);
@@ -234,7 +230,7 @@ fn dicts_ddl_equivalent(actual_ddl: &str, desired_ddl: &str) -> bool {
234230
'`' => in_backtick = true,
235231
'(' => depth += 1,
236232
')' => {
237-
depth -= 1;
233+
depth = depth.saturating_sub(1);
238234
if depth == 0 {
239235
end = start + off + ')'.len_utf8();
240236
break;

0 commit comments

Comments
 (0)