diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-09-24 10:30:53 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-09-24 10:30:53 -0700 |
commit | 51bbcda1c7f44f42055a032ed394dedeca6df954 (patch) | |
tree | 5771827b4a398e407e2038b56dbaeb4c9e7ffdfe | |
parent | Merge branch 'sg/split-index-test' (diff) | |
parent | linear-assignment: fix potential out of bounds memory access (diff) | |
download | tgif-51bbcda1c7f44f42055a032ed394dedeca6df954.tar.xz |
Merge branch 'tg/range-diff-corner-case-fix'
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
-rw-r--r-- | linear-assignment.c | 6 | ||||
-rwxr-xr-x | t/t3206-range-diff.sh | 5 |
2 files changed, 11 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); diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index d481f29259..045aca1c18 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -122,6 +122,11 @@ test_expect_success 'changed commit' ' test_cmp expected actual ' +test_expect_success 'no commits on one side' ' + git commit --amend -m "new message" && + git range-diff master HEAD@{1} HEAD +' + test_expect_success 'changed message' ' git range-diff --no-color topic...changed-message >actual && sed s/Z/\ /g >expected <<-EOF && |