Skip to content

Commit 8d9b5a4

Browse files
committed
rerere: plug conflict ID leaks
The merge_rr string list stores the conflict ID (a hexadecimal string that is used to index into $GIT_DIR/rr-cache) in the .util field of its elements, and when do_plain_rerere() resolves a conflict, the field is cleared. Also, when rerere_forget() recomputes the conflict ID to updates the preimage file, the conflict ID for the path is updated. We forgot to free the existing conflict ID when we did these two operations. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5eda906 commit 8d9b5a4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rerere.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
559559
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
560560
copy_file(rerere_path(name, "postimage"), path, 0666);
561561
mark_resolved:
562+
free(rr->items[i].util);
562563
rr->items[i].util = NULL;
563564
}
564565

@@ -627,6 +628,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
627628
char *hex;
628629
unsigned char sha1[20];
629630
int ret;
631+
struct string_list_item *item;
630632

631633
ret = handle_cache(path, sha1, NULL);
632634
if (ret < 1)
@@ -641,8 +643,9 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
641643
handle_cache(path, sha1, rerere_path(hex, "preimage"));
642644
fprintf(stderr, "Updated preimage for '%s'\n", path);
643645

644-
645-
string_list_insert(rr, path)->util = hex;
646+
item = string_list_insert(rr, path);
647+
free(item->util);
648+
item->util = hex;
646649
fprintf(stderr, "Forgot resolution for %s\n", path);
647650
return 0;
648651
}

0 commit comments

Comments
 (0)