Commit 151d81a647600601a867a1415336b74d4888d7d8

nulltoken 2012-07-12T22:03:28

refs: fix a memory leak

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/refs.c b/src/refs.c
index 13022c7..b3c140b 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1397,6 +1397,9 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
 	head_target = git_reference_target(head);
 
 	if (head_target && !strcmp(head_target, ref->name)) {
+		git_reference_free(head);
+		head = NULL;
+
 		if (git_reference_create_symbolic(&head, ref->owner, "HEAD", new_name, 1) < 0) {
 			giterr_set(GITERR_REFERENCE,
 				"Failed to update HEAD after renaming reference");