diff options
-rw-r--r-- | ref-filter.c | 7 | ||||
-rw-r--r-- | ref-filter.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/ref-filter.c b/ref-filter.c index 7b39303810..3fbbbeb88f 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -847,8 +847,10 @@ static struct ref_array_item *new_ref_array_item(const char *refname, const unsigned char *objectname, int flag) { - struct ref_array_item *ref = xcalloc(1, sizeof(struct ref_array_item)); - ref->refname = xstrdup(refname); + size_t len = strlen(refname); + struct ref_array_item *ref = xcalloc(1, sizeof(struct ref_array_item) + len + 1); + memcpy(ref->refname, refname, len); + ref->refname[len] = '\0'; hashcpy(ref->objectname, objectname); ref->flag = flag; @@ -889,7 +891,6 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid, static void free_array_item(struct ref_array_item *item) { free((char *)item->symref); - free(item->refname); free(item); } diff --git a/ref-filter.h b/ref-filter.h index 697b609064..699798400b 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -32,7 +32,7 @@ struct ref_array_item { int flag; const char *symref; struct atom_value *value; - char *refname; + char refname[FLEX_ARRAY]; }; struct ref_array { |