aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-10-24 10:15:50 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-10-24 10:15:50 -0700
commitd6643c7a5b8e5d8836a95c09a06253e43e158726 (patch)
treea191bfc4260a5afd9d2b8d471ebba389adacbcd0
parent29fbcd6e5715944b458965535bdd5bc302cc0996 (diff)
Fixed a memory allocation error.
-rw-r--r--src/inlines.c24
1 files changed, 12 insertions, 12 deletions
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;
}