diff options
| author | Junio C Hamano <gitster@pobox.com> | 2018-11-21 22:57:46 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2018-11-21 22:57:46 +0900 |
| commit | a357daeac6b95fa50b80404859d916c71320b79c (patch) | |
| tree | 1cdc984ed2f5f22ad0d8a98095c258afa4d68d01 /linear-assignment.c | |
| parent | 50e6df214d7f75559e4ad90c2fd1d8fc36938c8c (diff) | |
| parent | e467a90c7a82a047629aafa4e97daefa3872ec35 (diff) | |
Merge branch 'tg/range-diff-corner-case-fix' into maint
Recently added "range-diff" had a corner-case bug to cause it
segfault, which has been corrected.
* tg/range-diff-corner-case-fix:
linear-assignment: fix potential out of bounds memory access
Diffstat (limited to 'linear-assignment.c')
| -rw-r--r-- | linear-assignment.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/linear-assignment.c b/linear-assignment.c index 9b3e56e283..ecffc09be6 100644 --- a/linear-assignment.c +++ b/linear-assignment.c @@ -19,6 +19,12 @@ void compute_assignment(int column_count, int row_count, int *cost, int *free_row, free_count = 0, saved_free_count, *pred, *col; int i, j, phase; + if (column_count < 2) { + memset(column2row, 0, sizeof(int) * column_count); + memset(row2column, 0, sizeof(int) * row_count); + return; + } + memset(column2row, -1, sizeof(int) * column_count); memset(row2column, -1, sizeof(int) * row_count); ALLOC_ARRAY(v, column_count); |
