diff options
Diffstat (limited to 'src/transports/smart.c')
| -rw-r--r-- | src/transports/smart.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c index 79b5a3e6d..fdc9c116d 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); @@ -266,14 +268,21 @@ static int git_smart__connect( /* We now have loaded the refs. */ t->have_refs = 1; - first = (git_pkt_ref *)git_vector_get(&t->refs, 0); + pkt = (git_pkt *)git_vector_get(&t->refs, 0); + if (pkt && GIT_PKT_REF != pkt->type) { + giterr_set(GITERR_NET, "invalid response"); + return -1; + } + first = (git_pkt_ref *)pkt; if ((error = git_vector_init(&symrefs, 1, NULL)) < 0) return error; /* Detect capabilities */ - if (git_smart__detect_caps(first, &t->caps, &symrefs) < 0) + if (git_smart__detect_caps(first, &t->caps, &symrefs) < 0) { + free_symrefs(&symrefs); return -1; + } /* If the only ref in the list is capabilities^{} with OID_ZERO, remove it */ if (1 == t->refs.length && !strcmp(first->head.name, "capabilities^{}") && |
