diff options
author | Bjørn Mork <bjorn@mork.no> | 2022-09-14 19:15:01 +0200 |
---|---|---|
committer | Bjørn Mork <bjorn@mork.no> | 2022-09-14 19:15:01 +0200 |
commit | e53c2cc67e7ba389db2ceb81eb7cdb657a03548e (patch) | |
tree | 1d9e8189d4ddda2ef13c1977119b417cecc2d4b7 | |
parent | b1678c93b94b23780c0053dd722631d305bc85e5 (diff) |
fix refcountingv0.08
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | obinsectd.c | 3 |
2 files changed, 4 insertions, 1 deletions
@@ -1,4 +1,4 @@ -VERSION := 0.07 +VERSION := 0.08 LDFLAGS=$(shell pkg-config --libs json-c) $(shell pkg-config --libs libmosquitto) CFLAGS=-Wall $(shell pkg-config --cflags json-c) $(shell pkg-config --cflags libmosquitto) -DVERSION='"$(VERSION)"' -DWITH_TLS diff --git a/obinsectd.c b/obinsectd.c index 81430fe..f57aec8 100644 --- a/obinsectd.c +++ b/obinsectd.c @@ -1141,6 +1141,7 @@ static void add_keyval(json_object *pubcfg, json_object *pub, const char *key, j if (!json_object_object_get_ex(pubcfg, key, &tmp)) return; + /* take an extra refcount on val so we can use it in the loop below too */ json_object_object_add(pub, key, json_object_get(val)); for (i = 0; i < json_object_array_length(tmp); i++) { arrayname = json_object_get_string(json_object_array_get_idx(tmp, i)); @@ -1160,6 +1161,8 @@ static void add_keyval(json_object *pubcfg, json_object *pub, const char *key, j json_object_object_add(obj, key, json_object_get(val)); } + /* drop extra recount again */ + json_object_put(val); } static void set_current_list(const char *listname) |