aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-10-19 21:01:44 +0200
committerDavid Robillard <d@drobilla.net>2019-12-20 10:26:55 -0500
commit9ab6f1c0831fd2013c9db8c4a99f169ad80ddba0 (patch)
treeb1a820c0f53085a024c3883867c55292fb034054
parentc879104bdc18c1e7948f60a3711814b407d3e8af (diff)
downloadserd-9ab6f1c0831fd2013c9db8c4a99f169ad80ddba0.tar.gz
serd-9ab6f1c0831fd2013c9db8c4a99f169ad80ddba0.tar.bz2
serd-9ab6f1c0831fd2013c9db8c4a99f169ad80ddba0.zip
Fix memory leak in writer when caller doesn't clean up the stack
-rw-r--r--src/writer.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/writer.c b/src/writer.c
index 1e657d00..a1dd8d97 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -984,6 +984,11 @@ serd_writer_finish(SerdWriter* writer)
st = write_sep(writer, writer->context.flags, SEP_GRAPH_END);
}
+ // Free any lingering contexts in case there was an error
+ while (!serd_stack_is_empty(&writer->anon_stack)) {
+ pop_context(writer);
+ }
+
free_context(writer);
writer->indent = 0;
writer->context = WRITE_CONTEXT_NULL;