提交 fe4516d1 编写于 作者: P Phillip Wood 提交者: Junio C Hamano

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: NPhillip Wood <phillip.wood@dunelm.org.uk>
Reviewed-by: NStefan Beller <sbeller@google.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 cf074a9b
......@@ -811,10 +811,13 @@ static int compute_ws_delta(const struct emitted_diff_symbol *a,
const struct emitted_diff_symbol *shorter = a->len > b->len ? b : a;
int d = longer->len - shorter->len;
if (strncmp(longer->line + d, shorter->line, shorter->len))
return 0;
out->string = xmemdupz(longer->line, d);
out->current_longer = (a == longer);
return !strncmp(longer->line + d, shorter->line, shorter->len);
return 1;
}
static int cmp_in_block_with_wsd(const struct diff_options *o,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册