From b187e0541e9ac422168fc436429e79fbe70de7a7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 19 Oct 2019 21:01:44 +0200 Subject: Fix memory leak in writer when caller doesn't clean up the stack --- src/writer.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') 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; -- cgit v1.2.1