aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit4b18d70fbe4de50f1214749fe74261131dcc9da3 (patch)
tree41fc7876eade2d6ed3cb8396b7b9544d657c1b71
parentceb789e8c209de0155af4075ea6a1438576dc375 (diff)
downloadmandoc-4b18d70fbe4de50f1214749fe74261131dcc9da3.tar.gz
mandoc-4b18d70fbe4de50f1214749fe74261131dcc9da3.tar.zst
mandoc-4b18d70fbe4de50f1214749fe74261131dcc9da3.zip
Oops, that segfaulted after deleting an mlink from the list.
Fix the loop logic in mlinks_undupe().
-rw-r--r--mandocdb.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 0acd9924..ce0a7b4a 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.89 2013/12/27 20:35:51 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.90 2013/12/27 23:41:55 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;
}
}