diff options
author | David Robillard <d@drobilla.net> | 2019-10-19 21:01:44 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-06-21 18:12:04 +0200 |
commit | 9b46d6f04ba23c3967bab17de795d1a069be805f (patch) | |
tree | 7a3dec4f908727044dff1a275a01ad924ad23e77 | |
parent | d3dbdd3d22f8789cb090c2f62d451a45aea4f481 (diff) | |
download | serd-9b46d6f04ba23c3967bab17de795d1a069be805f.tar.gz serd-9b46d6f04ba23c3967bab17de795d1a069be805f.tar.bz2 serd-9b46d6f04ba23c3967bab17de795d1a069be805f.zip |
Fix memory leak in writer when caller doesn't clean up the stack
-rw-r--r-- | src/writer.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/writer.c b/src/writer.c index 7fbff37f..3d255e9b 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; |