From: Junio C Hamano Date: Wed, 27 Dec 2017 19:16:26 +0000 (-0800) Subject: Merge branch 'rs/fmt-merge-msg-leakfix' X-Git-Tag: v2.16.0-rc0~26 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/54b1335ae3ced34310fbc2abc92431a2a7f1f7fa?ds=inline;hp=-c Merge branch 'rs/fmt-merge-msg-leakfix' Leakfix. * rs/fmt-merge-msg-leakfix: transport-helper: plug strbuf and string_list leaks --- 54b1335ae3ced34310fbc2abc92431a2a7f1f7fa diff --combined transport-helper.c index bf05a2dcf1,3bbc105d80..413cd7b551 --- a/transport-helper.c +++ b/transport-helper.c @@@ -535,7 -535,7 +535,7 @@@ static int fetch_with_import(struct tra else private = xstrdup(name); if (private) { - if (read_ref(private, posn->old_oid.hash) < 0) + if (read_ref(private, &posn->old_oid) < 0) die("Could not read ref %s", private); free(private); } @@@ -795,8 -795,7 +795,8 @@@ static int push_update_refs_status(stru private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name); if (!private) continue; - update_ref("update by helper", private, ref->new_oid.hash, NULL, 0, 0); + update_ref("update by helper", private, &ref->new_oid, NULL, + 0, 0); free(private); } strbuf_release(&buf); @@@ -882,7 -881,8 +882,8 @@@ static int push_refs_with_push(struct t struct strbuf cas = STRBUF_INIT; strbuf_addf(&cas, "%s:%s", ref->name, oid_to_hex(&ref->old_oid_expect)); - string_list_append(&cas_options, strbuf_detach(&cas, NULL)); + string_list_append_nodup(&cas_options, + strbuf_detach(&cas, NULL)); } } if (buf.len == 0) { @@@ -897,6 -897,7 +898,7 @@@ strbuf_addch(&buf, '\n'); sendline(data, &buf); strbuf_release(&buf); + string_list_clear(&cas_options, 0); return push_update_refs_status(data, remote_refs, flags); } @@@ -930,7 -931,8 +932,8 @@@ static int push_refs_with_export(struc private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name); if (private && !get_oid(private, &oid)) { strbuf_addf(&buf, "^%s", private); - string_list_append(&revlist_args, strbuf_detach(&buf, NULL)); + string_list_append_nodup(&revlist_args, + strbuf_detach(&buf, NULL)); oidcpy(&ref->old_oid, &oid); } free(private); @@@ -942,9 -944,10 +945,9 @@@ int flag; /* Follow symbolic refs (mainly for HEAD). */ - name = resolve_ref_unsafe( - ref->peer_ref->name, - RESOLVE_REF_READING, - oid.hash, &flag); + name = resolve_ref_unsafe(ref->peer_ref->name, + RESOLVE_REF_READING, + &oid, &flag); if (!name || !(flag & REF_ISSYMREF)) name = ref->peer_ref->name; @@@ -1066,7 -1069,8 +1069,7 @@@ static struct ref *get_refs_list(struc if (eon) { if (has_attribute(eon + 1, "unchanged")) { (*tail)->status |= REF_STATUS_UPTODATE; - if (read_ref((*tail)->name, - (*tail)->old_oid.hash) < 0) + if (read_ref((*tail)->name, &(*tail)->old_oid) < 0) die(_("Could not read ref %s"), (*tail)->name); }