Welcome to little lamb

Code » qmdoc » commit 699cd37

Fix possible incorrect output with inline code

author Olivier Brunel
2023-01-12 19:43:50 UTC
committer Olivier Brunel
2023-01-12 19:43:50 UTC
parent 190fd619fd84f3cb0d581547ae1dfd9c8c134a6e

Fix possible incorrect output with inline code

When a TEXT_CODE is outputted, we check for ctx->code.flags to see if it
is being buffered or not. But, TEXT_CODE isn't only for code blocks but
also inline code, and if there had been a title before then we would
see an invalid value for ctx->code.flags because of ctx->title.level

So, don't union code & title to make sure things don't get messed up.

src/main.c +7 -9

diff --git a/src/main.c b/src/main.c
index 8c74cca..54502b7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -96,15 +96,13 @@ struct ctx {
         size_t salen;
         size_t otoc; /* where the page's TOC begins */
     } buf;
-    union {
-        struct {
-            int level;
-        } title;
-        struct {
-            int flags;
-            int from;
-        } code;
-    };
+    struct {
+        int level;
+    } title;
+    struct {
+        int flags;
+        int from;
+    } code;
 };
 
 #define BUFFERING_ON()  \