about summary refs log tree commit diff
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/shared.c b/shared.c
index c63f1e3..13a65a9 100644
--- a/shared.c
+++ b/shared.c
@@ -352,7 +352,7 @@ void cgit_diff_tree(const struct object_id *old_oid,
 	opt.format_callback = cgit_diff_tree_cb;
 	opt.format_callback_data = fn;
 	if (prefix) {
-		item.match = prefix;
+		item.match = xstrdup(prefix);
 		item.len = strlen(prefix);
 		opt.pathspec.nr = 1;
 		opt.pathspec.items = &item;
@@ -365,6 +365,8 @@ void cgit_diff_tree(const struct object_id *old_oid,
 		diff_root_tree_sha1(new_oid->hash, "", &opt);
 	diffcore_std(&opt);
 	diff_flush(&opt);
+
+	free(item.match);
 }
 
 void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix)