summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-05-04 09:53:03 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-05-04 09:53:03 -0700
commitf1035464022a8a4e804f5915e6a1388ea49e3fb3 (patch)
treecc3e3b14f1d7ff11c6eabb5766484762ecb504f3 /src
parentd12c040d58d70555cc98e397e05ab0d8326b6aca (diff)
Straightforward fix for memory leak #32.
Diffstat (limited to 'src')
-rw-r--r--src/iterator.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/iterator.c b/src/iterator.c
index c6faf99..8ed0cc4 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -121,6 +121,7 @@ void cmark_consolidate_text_nodes(cmark_node *root)
cmark_strbuf buf = GH_BUF_INIT;
cmark_event_type ev_type;
cmark_node *cur, *tmp, *next;
+ char *detached;
while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
cur = cmark_iter_get_node(iter);
@@ -138,7 +139,9 @@ void cmark_consolidate_text_nodes(cmark_node *root)
cmark_node_free(tmp);
tmp = next;
}
- cmark_node_set_literal(cur, (char *)cmark_strbuf_detach(&buf));
+ detached = (char *)cmark_strbuf_detach(&buf);
+ cmark_node_set_literal(cur, detached);
+ free(detached);
}
}