diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-03-23 14:09:31 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-23 14:09:31 -0700 |
commit | 361c2566c0aef409a7e266f0a3192a8f62f157a8 (patch) | |
tree | 7b724d6e4a709ff2dc7f32c829853a491eec3db2 /diff.c | |
parent | 1f390f2ad5aed63f87d0764e9748fddf9db4e59c (diff) | |
parent | 77e56d55ba6eee1c6efe08d4872e5001ed8e563a (diff) | |
download | git-361c2566c0aef409a7e266f0a3192a8f62f157a8.tar.gz |
Merge branch 'ab/plug-random-leaks'
Double-free fix for a recently merged topic.
* ab/plug-random-leaks:
diff.c: fix a double-free regression in a18d66cefb
tests: demonstrate "show --word-diff --color-moved" regression
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -800,6 +800,14 @@ static void append_emitted_diff_symbol(struct diff_options *o, f->line = e->line ? xmemdupz(e->line, e->len) : NULL; } +static void free_emitted_diff_symbols(struct emitted_diff_symbols *e) +{ + if (!e) + return; + free(e->buf); + free(e); +} + struct moved_entry { const struct emitted_diff_symbol *es; struct moved_entry *next_line; @@ -2150,7 +2158,6 @@ static void diff_words_flush(struct emit_callback *ecbdata) for (i = 0; i < wol->nr; i++) free((void *)wol->buf[i].line); - free(wol->buf); wol->nr = 0; } @@ -2228,7 +2235,7 @@ static void free_diff_words_data(struct emit_callback *ecbdata) { if (ecbdata->diff_words) { diff_words_flush(ecbdata); - free (ecbdata->diff_words->opt->emitted_symbols); + free_emitted_diff_symbols(ecbdata->diff_words->opt->emitted_symbols); free (ecbdata->diff_words->opt); free (ecbdata->diff_words->minus.text.ptr); free (ecbdata->diff_words->minus.orig); |