diff --color-moved-ws: fix a memory leak

Don't duplicate the indentation string if we're not going to use it. This was found with 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 fe4516d103e69e74513be33f78768ac43acf3daa
1 file changed +4 -1
diff.c
+4 -1
@@ -811,10 +811,13 @@ static int compute_ws_delta(const struct emitted_diff_symbol *a,
811 const struct emitted_diff_symbol *shorter = a->len > b->len ? b : a;
812 int d = longer->len - shorter->len;
813
814 + if (strncmp(longer->line + d, shorter->line, shorter->len))
815 + return 0;
816 +
817 out->string = xmemdupz(longer->line, d);
818 out->current_longer = (a == longer);
819
817 - return !strncmp(longer->line + d, shorter->line, shorter->len);
820 + return 1;
821 }
822
823 static int cmp_in_block_with_wsd(const struct diff_options *o,