summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/index.c b/index.c
index 4d7cfe9..a6d30f8 100644
--- a/index.c
+++ b/index.c
@@ -142,13 +142,15 @@ void build_index(index *i) {
t->nrefs = t->nexplicit;
ta = t->explicit_texts;
}
- t->refs = mknewa(indexentry *, t->nrefs);
- for (j = 0; j < t->nrefs; j++) {
- indexentry *ent = mknew(indexentry);
- ent->text = *ta++;
- t->refs[j] = add23(i->entries, ent, compare_entries);
- if (t->refs[j] != ent) /* duplicate */
- sfree(ent);
+ if (t->nrefs) {
+ t->refs = mknewa(indexentry *, t->nrefs);
+ for (j = 0; j < t->nrefs; j++) {
+ indexentry *ent = mknew(indexentry);
+ ent->text = *ta++;
+ t->refs[j] = add23(i->entries, ent, compare_entries);
+ if (t->refs[j] != ent) /* duplicate */
+ sfree(ent);
+ }
}
}
}