Commit 68c5ef5cc5392dc3b1895fdc03d4135536a9fa57

Vicent Martí 2012-07-13T06:53:33

Merge pull request #817 from nulltoken/fix/refs-leak 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");