ref-filter: initialize eaten variable
[gitweb.git] / ref-filter.c
index 8611c24fd57d19e364ad0e3ec5260c0e76dac33a..8db7ca95b12c09bb780b214aa6ca58722a26a007 100644 (file)
@@ -1439,7 +1439,8 @@ static const char *get_refname(struct used_atom *atom, struct ref_array_item *re
 static int get_object(struct ref_array_item *ref, const struct object_id *oid,
                       int deref, struct object **obj, struct strbuf *err)
 {
-       int eaten;
+       /* parse_object_buffer() will set eaten to 0 if free() will be needed */
+       int eaten = 1;
        int ret = 0;
        unsigned long size;
        void *buf = get_obj(oid, obj, &size, &eaten);
@@ -1497,6 +1498,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
                        refname = get_symref(atom, ref);
                else if (starts_with(name, "upstream")) {
                        const char *branch_name;
+                       v->s = "";
                        /* only local branches may have an upstream */
                        if (!skip_prefix(ref->refname, "refs/heads/",
                                         &branch_name))
@@ -1509,6 +1511,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
                        continue;
                } else if (atom->u.remote_ref.push) {
                        const char *branch_name;
+                       v->s = "";
                        if (!skip_prefix(ref->refname, "refs/heads/",
                                         &branch_name))
                                continue;
@@ -1549,22 +1552,26 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
                        continue;
                } else if (starts_with(name, "align")) {
                        v->handler = align_atom_handler;
+                       v->s = "";
                        continue;
                } else if (!strcmp(name, "end")) {
                        v->handler = end_atom_handler;
+                       v->s = "";
                        continue;
                } else if (starts_with(name, "if")) {
                        const char *s;
-
+                       v->s = "";
                        if (skip_prefix(name, "if:", &s))
                                v->s = xstrdup(s);
                        v->handler = if_atom_handler;
                        continue;
                } else if (!strcmp(name, "then")) {
                        v->handler = then_atom_handler;
+                       v->s = "";
                        continue;
                } else if (!strcmp(name, "else")) {
                        v->handler = else_atom_handler;
+                       v->s = "";
                        continue;
                } else
                        continue;