Merge branch 'jp/get-ref-dir-unsorted' into next

* jp/get-ref-dir-unsorted:
  refs.c: free duplicate entries in the ref array instead of leaking them
  refs.c: abort ref search if ref array is empty
  refs.c: ensure struct whose member may be passed to realloc is initialized

Conflicts:
	refs.c
This commit is contained in:
Junio C Hamano
2011-10-10 15:28:31 -07:00

4
refs.c
View File

@@ -96,6 +96,7 @@ static void sort_ref_array(struct ref_array *array)
die("Duplicated ref, and SHA1s don't match: %s",
a->name);
warning("Duplicated ref: %s", a->name);
free(b);
continue;
}
i++;
@@ -112,6 +113,9 @@ static struct ref_entry *search_ref_array(struct ref_array *array, const char *n
if (name == NULL)
return NULL;
if (!array->nr)
return NULL;
len = strlen(name) + 1;
e = xmalloc(sizeof(struct ref_entry) + len);
memcpy(e->name, name, len);