Commit 67924ee
committed
Add guard when converting from i64 to usize
In some cases, when bad data is passed in as a set of change to
parinfer-rust it can cause parinfer-rust to crash. This crash is
caused by trying to add indents to a line. When the delta calculated
turns out to be negative and when that is added to orig_indent that
can cause issues when type casting to usize (Column). This is because
the combination of these two variables can be negative and when type
cast to a usize it causes the number to be very large, in my case
something like 1.8 trillion. So when this number is then used to
determine how many times to repeat a string, it causes the library to
run out of memory and crash.1 parent bcfdcd1 commit 67924ee
2 files changed
+17
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
582 | 597 | | |
583 | 598 | | |
584 | 599 | | |
| |||
1429 | 1444 | | |
1430 | 1445 | | |
1431 | 1446 | | |
1432 | | - | |
| 1447 | + | |
1433 | 1448 | | |
1434 | 1449 | | |
1435 | 1450 | | |
| |||
0 commit comments