diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 86f56b01..4662529b 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -2336,9 +2336,14 @@ mod tests { depth += 1; } b'}' => { - depth -= 1; - if depth == 0 { - return open.map(|o| (o, i)); + // A closer seen BEFORE the body opened is not ours (it can + // only come from a signature or a type ascription the scan + // mis-read); ignore it rather than underflowing `depth`. + if depth > 0 { + depth -= 1; + if depth == 0 { + return open.map(|o| (o, i)); + } } } _ => {}