Commit 585a2eb75adb71cb6bf73e548a23f86b30de2d4a

Carlos Martín Nieto 2012-01-19T17:05:16

remote: don't try to free the ref on error On error, the pointer could be pointing anywhere.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/remote.c b/src/remote.c
index ef42c6e..cdf2878 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -279,9 +279,10 @@ int git_remote_update_tips(git_remote *remote)
 	if (!strcmp(head->name, GIT_HEAD_FILE)) {
 		error = git_reference_create_oid(&ref, remote->repo, GIT_FETCH_HEAD_FILE, &head->oid, 1);
 		i = 1;
-		git_reference_free(ref);
 		if (error < GIT_SUCCESS)
 			return git__rethrow(error, "Failed to update FETCH_HEAD");
+
+		git_reference_free(ref);
 	}
 
 	for (; i < refs->length; ++i) {