summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-12-27 23:41:55 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-12-27 23:41:55 +0000
commitc50fcb020d6b89ff503f7bc4bb8a3cc272fcbabe (patch)
treeb9ff54c0b1b6b347d3f0d1e2992b42af15fb96ef /mandocdb.c
parent4681fc64c6fb8b5c3f1ac156ffaf97e5587e2ab1 (diff)
downloadmandoc-c50fcb020d6b89ff503f7bc4bb8a3cc272fcbabe.tar.gz
Oops, that segfaulted after deleting an mlink from the list.
Fix the loop logic in mlinks_undupe().
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/mandocdb.c b/mandocdb.c
index a00ef183..342539cc 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -855,16 +855,16 @@ mlinks_undupe(struct mpage *mpage)
char *bufp;
mpage->form = FORM_CAT;
- for(prev = &mpage->mlinks; *prev; prev = &(*prev)->next) {
- mlink = *prev;
+ prev = &mpage->mlinks;
+ while (NULL != (mlink = *prev)) {
if (FORM_CAT != mlink->dform) {
mpage->form = FORM_NONE;
- continue;
+ goto nextlink;
}
if (strlcpy(buf, mlink->file, PATH_MAX) >= PATH_MAX) {
if (warnings)
say(mlink->file, "Filename too long");
- continue;
+ goto nextlink;
}
bufp = strstr(buf, "cat");
assert(NULL != bufp);
@@ -874,14 +874,16 @@ mlinks_undupe(struct mpage *mpage)
strlcat(buf, mlink->dsec, PATH_MAX);
if (NULL == ohash_find(&mlinks,
ohash_qlookup(&mlinks, buf)))
- continue;
+ goto nextlink;
if (warnings)
say(mlink->file, "Man source exists: %s", buf);
if (use_all)
- continue;
+ goto nextlink;
*prev = mlink->next;
mlink_free(mlink);
- mlink = *prev;
+ continue;
+nextlink:
+ prev = &(*prev)->next;
}
}