Anonymous committed 03b69c7

Fix small memory leaks induced by diff_tree_setup_paths

Run diff_tree_release_paths in the appropriate places, and add a test to
avoid NULL dereference. Better safe than sorry.

Signed-off-by: Mike Hommey <>
Signed-off-by: Junio C Hamano <>

Comments (0)

Files changed (3)

+	diff_tree_release_paths(&diff_opts);
 	if (porigin) {
 		 * Create a freestanding copy that is not part of
+	diff_tree_release_paths(&diff_opts);
 	return porigin;
+	diff_tree_release_paths(&diff_opts);
 	return retval;
 		return 1;
+	diff_tree_release_paths(&opt);
 	if (!index_was_discarded)
 		/* The index is still clobbered from do_diff_cache() */
 		die("unable to set up diff options to follow renames");
 	diff_tree(t1, t2, base, &diff_opts);
+	diff_tree_release_paths(&diff_opts);
 	/* Go through the new set of filepairing, and see if we find a more interesting one */
 	for (i = 0; i < q->nr; i++) {
 			choice = p;
 			/* Update the path we use from now on.. */
+			diff_tree_release_paths(opt);
 			opt->paths[0] = xstrdup(p->one->path);
 			diff_tree_setup_paths(opt->paths, opt);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.