From aabe834a59a1debd38b159fa967f31fb2b4c2a76 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Fri, 16 Sep 2022 12:43:17 +0200 Subject: always drop ref when changing current_list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- Makefile | 2 +- obinsectd.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8fb35af..c6a5d80 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 0.11 +VERSION := 0.12 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 82094bf..81afdfa 100644 --- a/obinsectd.c +++ b/obinsectd.c @@ -1198,6 +1198,8 @@ static void set_current_list(const char *listname) obiscode[i] = NULL; /* save list pointer */ + if (current_list) + json_object_put(current_list); current_list = json_object_get(list); debug("Current OBIS list set to '%s\n", listname); } @@ -1255,7 +1257,7 @@ static json_object *format_value(const char *key, json_object *val) /* we can drop val now */ json_object_put(val); - + if (ifactor) { if (!unit) return json_object_new_int(ival * ifactor); @@ -2095,8 +2097,6 @@ err: sleep(1); /* give the mosquitto lib some time to flush remaining messages - FIXME: there gotta be a better way? */ free(buf); free(printbuffer); - if (current_list) - json_object_put(current_list); if (cfg) json_object_put(cfg); mosquitto_disconnect(mosq); -- cgit v1.2.3