Commit d248417
committed
fix: prevent integer underflow in amount() bounds check
The bounds check 'index > arr.size() - 1' has an edge case bug.
When arr.size() is 0, subtracting 1 from an unsigned size_t
underflows to SIZE_MAX, so 'index > SIZE_MAX' is always false.
This could theoretically allow out-of-bounds access, though it's
pretty hard to trigger in practice - would need a malformed/corrupted
unsigned_tx file that parses successfully but has no transactions.
Changed to 'arr.empty() || index >= arr.size()' which handles
the edge case properly.
Found with AddressSanitizer during fuzzing.1 parent 42dc35d commit d248417
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
0 commit comments