aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-10-19 21:01:44 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:59 +0100
commitb187e0541e9ac422168fc436429e79fbe70de7a7 (patch)
tree6dafbbf6bf4d27b8676c8df1c8be37e0092143bb /src/writer.c
parent3c5ccf16e7dc0eef903c3c49958559cb4a3a370b (diff)
downloadserd-b187e0541e9ac422168fc436429e79fbe70de7a7.tar.gz
serd-b187e0541e9ac422168fc436429e79fbe70de7a7.tar.bz2
serd-b187e0541e9ac422168fc436429e79fbe70de7a7.zip
Fix memory leak in writer when caller doesn't clean up the stack
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/writer.c b/src/writer.c
index a47252c8..acb63d7d 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -1029,6 +1029,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;