From 83297e97be8e34e4f92f748f967f8acf6fb2ea1c Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 19 May 2016 20:37:59 +0200 Subject: [PATCH] client: remove memory leak introduced in JSON writers --- src/client/jansson_writer.c | 1 + src/client/jsonc_writer.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/client/jansson_writer.c b/src/client/jansson_writer.c index c14ad8c4..0fb179d9 100644 --- a/src/client/jansson_writer.c +++ b/src/client/jansson_writer.c @@ -188,6 +188,7 @@ jansson_finish(struct writer *w) /* memory will leak... */ } else { struct json_element *root = TAILQ_FIRST(&p->els); + json_decref(root->el); TAILQ_REMOVE(&p->els, root, next); free(root); } diff --git a/src/client/jsonc_writer.c b/src/client/jsonc_writer.c index 90a2513b..332712e7 100644 --- a/src/client/jsonc_writer.c +++ b/src/client/jsonc_writer.c @@ -182,6 +182,7 @@ jsonc_finish(struct writer *w) /* memory will leak... */ } else { struct json_element *root = TAILQ_FIRST(&p->els); + json_object_put(root->el); TAILQ_REMOVE(&p->els, root, next); free(root); } -- 2.39.5