Commit 8e158b0141b7625e7db96d7ff32f7312b08d2740

Stefan Sperling 2019-09-22T13:12:33

plug logmsg memory leak in cmd_import; found by jj@ with scan-build

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/got/got.c b/got/got.c
index bc507c2..e9a814c 100644
--- a/got/got.c
+++ b/got/got.c
@@ -675,6 +675,7 @@ cmd_import(int argc, char *argv[])
 		error = get_editor(&editor);
 		if (error)
 			goto done;
+		free(logmsg);
 		error = collect_import_msg(&logmsg, editor, path_dir, refname);
 		if (error)
 			goto done;
@@ -722,6 +723,7 @@ cmd_import(int argc, char *argv[])
 	printf("Created branch %s with commit %s\n",
 	    got_ref_get_name(branch_ref), id_str);
 done:
+	free(logmsg);
 	free(repo_path);
 	free(editor);
 	free(refname);