Welcome to little lamb

Code » qmdoc » commit 095c13a

Fix possible segfault

author Olivier Brunel
2023-07-07 12:15:29 UTC
committer Olivier Brunel
2023-07-07 16:59:36 UTC
parent 655fc9a7ecd2a6abc22bb8675adae3f5bd7de501

Fix possible segfault

Detecting whether or not there are pages/something to do forgot to account
for the index, which we might auto-add and thus doesn't count.

src/qmdoc/qmdoc.c +4 -2

diff --git a/src/qmdoc/qmdoc.c b/src/qmdoc/qmdoc.c
index b77ded6..3b3edd1 100644
--- a/src/qmdoc/qmdoc.c
+++ b/src/qmdoc/qmdoc.c
@@ -2159,6 +2159,10 @@ main (int argc, const char *argv[])
         genalloc_free(int, &ga_sg);
     }
 
+    /* check now before maybe adding our own index, to test if there are any
+     * /user/ pages to process.  */
+    if (!NB_PAGES(&ctx)) dief(EX_NOINPUT, "nothing to do");
+
     if (idx_mode != IDX_DISABLED) {
         ctx.doc.flags |= DOC_FULL_TOC;
 
@@ -2193,8 +2197,6 @@ main (int argc, const char *argv[])
         }
     }
 
-    if (NB_PAGES(&ctx) == 0) dief(EX_NOINPUT, "nothing to do");
-
     if (parse.header != (size_t) -1 || parse.footer != (size_t) -1) {
         quiet("Loading files...");