fixed segv if first line of file is HR, closes #27
authorMichael Göhler <somebody.here@gmx.de>
Fri, 19 Sep 2014 20:45:35 +0000 (22:45 +0200)
committerMichael Göhler <somebody.here@gmx.de>
Fri, 19 Sep 2014 20:45:35 +0000 (22:45 +0200)
parser.c

index 8489ab0..1ff125c 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -53,9 +53,15 @@ deck_t *markdown_load(FILE *input) {
             // markdown analyse
             bits = markdown_analyse(text);
 
+            // if first line in file is markdown hr
+            if(!line && CHECK_BIT(bits, IS_HR)) {
+
+                // clear text
+                (text->reset)(text);
+
             // if text is markdown hr
-            if(CHECK_BIT(bits, IS_HR) &&
-               CHECK_BIT(line->bits, IS_EMPTY)) {
+            } else if(CHECK_BIT(bits, IS_HR) &&
+                      CHECK_BIT(line->bits, IS_EMPTY)) {
 
                 slide->lines = lc;