Thread (3 messages) 3 messages, 2 authors, 2025-12-18

Re: [PATCH] repository: cache->squash_msg is freed twice

From: Eric Sunshine <hidden>
Date: 2025-12-18 18:18:44

On Thu, Dec 18, 2025 at 10:26 AM AZero13 via GitGitGadget
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
Thankfully, it is set to NULL, so no security consequences.
However, this is still a mistake that must be rectified.

Signed-off-by: Greg Funni <redacted>
---
diff --git a/repository.c b/repository.c
@@ -349,7 +349,6 @@ out:
 static void repo_clear_path_cache(struct repo_path_cache *cache)
 {
-       FREE_AND_NULL(cache->squash_msg);
        FREE_AND_NULL(cache->squash_msg);
        FREE_AND_NULL(cache->merge_msg);
        FREE_AND_NULL(cache->merge_rr);
This mistake has been present since Ævar added this function in
759f340738 (repository.c: free the "path cache" in repo_clear(),
2022-03-04), so it isn't the result of someone else coming along and
adding a new field to the structure which needs freeing but then
botching the call to FREE_AND_NULL(). Moreover, this function does
free all the freeable members of repo_path_cache, hence, nothing is
being leaked, so it must have just been a silly copy/paste mistake in
the first place. Hence, this change makes sense.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help