+8
-6
index 53ca25c814..6a157e34ce 100644
--- a/notes.c
+++ b/notes.c
{
memset(opt, 0, sizeof(*opt));
opt->use_default_notes = -1;
+ string_list_init_dup(&opt->extra_notes_refs);
+}
+
+void release_display_notes(struct display_notes_opt *opt)
+{
+ string_list_clear(&opt->extra_notes_refs, 0);
}
void enable_default_display_notes(struct display_notes_opt *opt, int *show_notes)
struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, ref);
expand_notes_ref(&buf);
- string_list_append(&opt->extra_notes_refs,
- strbuf_detach(&buf, NULL));
+ string_list_append_nodup(&opt->extra_notes_refs,
+ strbuf_detach(&buf, NULL));
*show_notes = 1;
}
void disable_display_notes(struct display_notes_opt *opt, int *show_notes)
{
opt->use_default_notes = -1;
- /* we have been strdup'ing ourselves, so trick
- * string_list into free()ing strings */
- opt->extra_notes_refs.strdup_strings = 1;
string_list_clear(&opt->extra_notes_refs, 0);
- opt->extra_notes_refs.strdup_strings = 0;
*show_notes = 0;
}
+5
index 064fd7143a..235216944b 100644
--- a/notes.h
+++ b/notes.h
*/
void init_display_notes(struct display_notes_opt *opt);
+/*
+ * Release resources acquired by the display_notes_opt.
+ */
+void release_display_notes(struct display_notes_opt *opt);
+
/*
* This family of functions enables or disables the display of notes. In
* particular, 'enable_default_display_notes' will display the default notes,
+1
index af95502d92..75e71bcaea 100644
--- a/revision.c
+++ b/revision.c
{
free_commit_list(revs->commits);
free_commit_list(revs->ancestry_path_bottoms);
+ release_display_notes(&revs->notes_opt);
object_array_clear(&revs->pending);
object_array_clear(&revs->boundary_commits);
release_revisions_cmdline(&revs->cmdline);
+1
index cf23c06c09..536bd11ff4 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
test_description='Test commit notes'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
write_script fake_editor <<\EOF