From b3096982b578400aaf663caed1cdbf9e3897a686 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 23 Mar 2022 22:29:51 +0000 Subject: [PATCH] Fix Coverity Scan 1486953 Use after free --- plugins/persist-sqlite/base_msgs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/persist-sqlite/base_msgs.c b/plugins/persist-sqlite/base_msgs.c index f6a4b6bc5..895c2c3fc 100644 --- a/plugins/persist-sqlite/base_msgs.c +++ b/plugins/persist-sqlite/base_msgs.c @@ -115,7 +115,10 @@ static char *properties_to_json(const mosquitto_property *properties) case MQTT_PROP_SERVER_REFERENCE: case MQTT_PROP_REASON_STRING: /* str */ - mosquitto_property_read_string(properties, propid, &value, false); + if(mosquitto_property_read_string(properties, propid, &value, false)){ + cJSON_Delete(array); + return NULL; + } if(cJSON_AddStringToObject(obj, "value", value) == NULL){ free(value); cJSON_Delete(array);