Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
diff --color-moved-ws: fix a memory leak
author
Phillip Wood
<phillip.wood@dunelm.org.uk>
Thu, 4 Oct 2018 10:07:43 +0000
(11:07 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 5 Oct 2018 05:48:12 +0000
(22:48 -0700)
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>
diff.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
cf074a9
)
diff --git
a/diff.c
b/diff.c
index 6f122121344b6043fbe3d996777f6766bfaafb9a..38f26091f313c9b63331718168e5d69ee148832b 100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-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,