Commit cf33592876b2aa0a575c08b782313ba0a2c76f8f

Nelson Elhage 2018-06-24T22:22:40

git_smart__update_heads: free the old symref_target

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 79b5a3e..e83a3c5 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -167,8 +167,10 @@ int git_smart__update_heads(transport_smart *t, git_vector *symrefs)
 			git_vector_foreach(symrefs, j, spec) {
 				git_buf_clear(&buf);
 				if (git_refspec_src_matches(spec, ref->head.name) &&
-				    !(error = git_refspec_transform(&buf, spec, ref->head.name)))
+				    !(error = git_refspec_transform(&buf, spec, ref->head.name))) {
+					git__free(ref->head.symref_target);
 					ref->head.symref_target = git_buf_detach(&buf);
+				}
 			}
 
 			git_buf_dispose(&buf);