From d6643c7a5b8e5d8836a95c09a06253e43e158726 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 24 Oct 2014 10:15:50 -0700 Subject: Fixed a memory allocation error. --- src/inlines.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/inlines.c') diff --git a/src/inlines.c b/src/inlines.c index d24235a..07a75f9 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -293,6 +293,16 @@ static int scan_delims(subject* subj, char c, bool * can_open, bool * can_close) return numdelims; } +static void free_openers(subject* subj, inline_stack* istack) +{ + inline_stack * tempstack; + while (subj->emphasis_openers != istack) { + tempstack = subj->emphasis_openers; + subj->emphasis_openers = subj->emphasis_openers->previous; + free(tempstack); + } +} + // Parse strong/emph or a fallback. // Assumes the subject has '_' or '*' at the current position. static node_inl* handle_strong_emph(subject* subj, char c, node_inl **last) @@ -301,7 +311,6 @@ static node_inl* handle_strong_emph(subject* subj, char c, node_inl **last) int numdelims; int useDelims; inline_stack * istack; - inline_stack * tempstack; node_inl * inl; node_inl * emph; node_inl * inl_text; @@ -338,11 +347,7 @@ static node_inl* handle_strong_emph(subject* subj, char c, node_inl **last) inl->next = NULL; // remove this opener and all later ones from stack: - while (subj->emphasis_openers != istack->previous) { - tempstack = subj->emphasis_openers; - free(tempstack); - subj->emphasis_openers = subj->emphasis_openers->previous; - } + free_openers(subj, istack->previous); *last = inl; } else @@ -356,12 +361,7 @@ static node_inl* handle_strong_emph(subject* subj, char c, node_inl **last) inl->next = emph; // remove all later openers from stack: - while (subj->emphasis_openers != istack) { - tempstack = subj->emphasis_openers; - free(tempstack); - subj->emphasis_openers = subj->emphasis_openers->previous; - } - + free_openers(subj, istack); *last = emph; } -- cgit v1.2.3