diff --color-moved-ws: fix out of bounds string access
When adjusting the start of the string to take account of the change in indentation the code was not checking that the string being adjusted was in fact longer than the indentation change. This was detected by asan. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Oct 4, 2018 at 11:07 UTC
cf074a9b0e589bad8e6b210ac1e3a4714463f7db
1 file changed
+1
-1
diff.c
+1
-1
@@ -865,7 +865,7 @@ static int cmp_in_block_with_wsd(const struct diff_options *o,
865
al -= wslen;
866
}
867
868
- if (strcmp(a, c))
868
+ if (al != cl || memcmp(a, c, al))
869
return 1;
870
871
return 0;