Skip to contentSkip to conversation

builtin-rerere: fix a small leak

PATCH In review Junio C Hamano 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 builtin-rerere: fix a small leak

The data read from MERGE_RR file is kept in path-list by hanging textual 40-byte conflict signature to path of the blob that contains the conflict. The signature is strdup'ed twice, and the second copy is given to the path-list, leaking the first copy.

---
* Am I overlooking something obvious, or is this simply a never-reviewed buglet that nobody has noticed for a long time?

 builtin-rerere.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-rerere.c +1 -1
index 5c81142..85222d9 100644
@@ -43,7 +43,7 @@ static void read_rr(struct path_list *rr)
 			; /* do nothing */
 		if (i == sizeof(buf))
 			die("filename too long");
-		path_list_insert(buf, rr)->util = xstrdup(name);
+		path_list_insert(buf, rr)->util = name;
 	}
 	fclose(in);
 }
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 9 lines · Junio C Hamano

The data read from MERGE_RR file is kept in path-list by hanging textual 40-byte conflict signature to path of the blob that contains the conflict. The signature is strdup'ed twice, and the second copy is given to the path-list, leaking the first copy.

---
* Am I overlooking something obvious, or is this simply a never-reviewed buglet that nobody has noticed for a long time?

I think that it was a never-reviewed buglet. The only code path leading to read_rr passes merge_rr, which has strdup_paths == 1.

Ciao,
Dscho