summaryrefslogtreecommitdiff
path: root/index.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>1999-10-25 16:24:41 +0000
committerSimon Tatham <anakin@pobox.com>1999-10-25 16:24:41 +0000
commit58b8771ff9a9c397ea49605db216a5e5a777c057 (patch)
tree4c27603e22c24e8383a59f6cc175fc9a71e1eea7 /index.c
parente51e74249b8990672b1420c6edcf608ca292533a (diff)
downloadhalibut-58b8771ff9a9c397ea49605db216a5e5a777c057.zip
halibut-58b8771ff9a9c397ea49605db216a5e5a777c057.tar.gz
halibut-58b8771ff9a9c397ea49605db216a5e5a777c057.tar.bz2
halibut-58b8771ff9a9c397ea49605db216a5e5a777c057.tar.xz
Fix a slight oddity in index generation, revealed by error testing
[originally from svn r256]
Diffstat (limited to 'index.c')
-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);
+ }
}
}
}