Subject: [PATCH] fixup! read-cache.c: fix memory leaks caused by removed cache, entries

From: Karsten Blees <[email-masked]>
Date: Tue, 22 Oct 2013 15:13:17 +0200

...another instance where we access a free()d ce.

Signed-off-by: Karsten Blees <[email-masked]>
---

Am 19.10.2013 21:28, schrieb Thomas Rast:
> 
> Is this the version that is currently in pu?

No, its from a rebased-to-next version [1]. I didn't resend the patches because nothing actually changed (except diff contexts). Sorry for the inconvenience.

> In any case 36850edb currently breaks several valgrind tests.  You can
> valgrind only t6022.16 like so (that one test is sufficient to track it
> down and it's much faster that way):
> 
>   cd t  
>   ./t6022-merge-rename.sh --valgrind-only=16
> 

Thanks, here's the fix.

Karsten

[1] https://github.com/kblees/git/commits/kb/hashmap-v3-next

 read-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/read-cache.c b/read-cache.c
index fe90c3b..3f735f3 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1898,7 +1898,7 @@ int read_index_unmerged(struct index_state *istate)
 		new_ce->ce_mode = ce->ce_mode;
 		if (add_index_entry(istate, new_ce, 0))
 			return error("%s: cannot drop to stage #0",
-				     ce->name);
+				     new_ce->name);
 		i = index_name_pos(istate, new_ce->name, len);
 	}
 	return unmerged;
-- 
1.8.4.msysgit.0.12.g88f5ed0.dirty