lane-av1refusalspan: a closer seen before the body opens is not ours
Browse files at this commiteec2f7d28305723a527c1cf881c2945ff0823da3Parent: 8a8b3cf1 changed file +8 -3
crates/ec-av1/src/refusal_inventory.rsmodified+8 -3
| @@ -2336,9 +2336,14 @@ mod tests { | ||
| 2336 | 2336 | depth += 1; |
| 2337 | 2337 | } |
| 2338 | 2338 | b'}' => { |
| 2339 | - depth -= 1; | |
| 2340 | - if depth == 0 { | |
| 2341 | - return open.map(|o| (o, i)); | |
| 2339 | + // A closer seen BEFORE the body opened is not ours (it can | |
| 2340 | + // only come from a signature or a type ascription the scan | |
| 2341 | + // mis-read); ignore it rather than underflowing `depth`. | |
| 2342 | + if depth > 0 { | |
| 2343 | + depth -= 1; | |
| 2344 | + if depth == 0 { | |
| 2345 | + return open.map(|o| (o, i)); | |
| 2346 | + } | |
| 2342 | 2347 | } |
| 2343 | 2348 | } |
| 2344 | 2349 | _ => {} |