Merge branch 'rs/fmt-merge-msg-leakfix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 27 Dec 2017 19:16:26 +0000 (11:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Dec 2017 19:16:26 +0000 (11:16 -0800)
Leakfix.

* rs/fmt-merge-msg-leakfix:
transport-helper: plug strbuf and string_list leaks

1  2 
transport-helper.c
diff --combined transport-helper.c
index bf05a2dcf1073ad3b84b030cd9e866c6e5414792,3bbc105d80cf6ea8d193248dea4b3bfd02cd4415..413cd7b5518c930eda526f37f0797ffbf31e33c8
@@@ -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) {
        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);
                                        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);
                        }