"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
got: don't leak pathlist in commit and revert commands
To:
Game of Trees <gameoftrees@openbsd.org>
Date:
Sun, 22 Jan 2023 23:47:04 +1100

Download raw body.

Thread
As per the subject, spotted these pathlist leaks while studying the code
for stsp's recent cherrypick/reverse-merge ref metadata idea.

In both instances, 'paths' is initialised and passed to
get_worktree_paths_from_argv() where each added entry's path pointer is
heap allocated, so pass the GOT_PATHLIST_FREE_PATH flag to make sure
they're also freed.

-----------------------------------------------
commit e823287df3b73d3a120cc64dd084eaabaed3dc31 (main)
from: Mark Jamsek <mark@jamsek.dev>
date: Sun Jan 22 12:29:35 2023 UTC
 
 got: don't leak pathlist in commit and revert commands
 
diff 85fa2e37e235526deaa3e716c685069d9915cf89 e823287df3b73d3a120cc64dd084eaabaed3dc31
commit - 85fa2e37e235526deaa3e716c685069d9915cf89
commit + e823287df3b73d3a120cc64dd084eaabaed3dc31
blob - f1564fe9067f8708e5f87d50539aa46985cdc197
blob + cdcbeb71f9090dc6023894262edf4802c8cb907c
--- got/got.c
+++ got/got.c
@@ -8522,6 +8522,7 @@ done:
 		if (error == NULL)
 			error = pack_err;
 	}
+	got_pathlist_free(&paths, GOT_PATHLIST_FREE_PATH);
 	free(path);
 	free(cwd);
 	return error;
@@ -8873,6 +8874,7 @@ done:
 		if (error == NULL)
 			error = pack_err;
 	}
+	got_pathlist_free(&paths, GOT_PATHLIST_FREE_PATH);
 	free(cwd);
 	free(id_str);
 	free(gitconfig_path);

-- 
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68