refs.c: abort ref search if ref array is empty
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index c31b4616629b0c822ec03669e1e3091bb6d56403..cbc4c5d28d3252a3336cfa370cb3d720d5d8556d 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -110,6 +110,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);