From: Fletcher T. Penney Date: Sun, 30 Jul 2017 18:48:07 +0000 (-0400) Subject: FIXED: Fix potential crash X-Git-Tag: 6.2.0^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=604619f7994f317a51a09e104aa5b1688851fab4;p=multimarkdown FIXED: Fix potential crash --- diff --git a/Sources/libMultiMarkdown/mmd.c b/Sources/libMultiMarkdown/mmd.c index 1385975..70fe0a3 100644 --- a/Sources/libMultiMarkdown/mmd.c +++ b/Sources/libMultiMarkdown/mmd.c @@ -544,43 +544,48 @@ void mmd_assign_line_type(mmd_engine * e, token * line) { break; case TEXT_NUMBER_POSS_LIST: - switch (source[first_child->next->start]) { - case ' ': - case '\t': - line->type = LINE_LIST_ENUMERATED; - first_child->type = MARKER_LIST_ENUMERATOR; - - switch (first_child->next->type) { - case TEXT_PLAIN: - - // Strip whitespace between bullet and text - while (char_is_whitespace(source[first_child->next->start])) { - first_child->next->start++; - first_child->next->len--; - } + if (first_child->next) { + switch (source[first_child->next->start]) { + case ' ': + case '\t': + line->type = LINE_LIST_ENUMERATED; + first_child->type = MARKER_LIST_ENUMERATOR; - break; + switch (first_child->next->type) { + case TEXT_PLAIN: - case INDENT_SPACE: - case INDENT_TAB: - case NON_INDENT_SPACE: - t = first_child; + // Strip whitespace between bullet and text + while (char_is_whitespace(source[first_child->next->start])) { + first_child->next->start++; + first_child->next->len--; + } - while (t->next && ((t->next->type == INDENT_SPACE) || - (t->next->type == INDENT_TAB) || - (t->next->type == NON_INDENT_SPACE))) { - tokens_prune(t->next, t->next); - } + break; - break; - } + case INDENT_SPACE: + case INDENT_TAB: + case NON_INDENT_SPACE: + t = first_child; - break; + while (t->next && ((t->next->type == INDENT_SPACE) || + (t->next->type == INDENT_TAB) || + (t->next->type == NON_INDENT_SPACE))) { + tokens_prune(t->next, t->next); + } - default: - line->type = LINE_PLAIN; - first_child->type = TEXT_PLAIN; - break; + break; + } + + break; + + default: + line->type = LINE_PLAIN; + first_child->type = TEXT_PLAIN; + break; + } + } else { + line->type = LINE_LIST_ENUMERATED; + first_child->type = MARKER_LIST_ENUMERATOR; } break;