diff --git a/plugins/persist-sqlite/base_msgs.c b/plugins/persist-sqlite/base_msgs.c index d158fcd1..7a934c5d 100644 --- a/plugins/persist-sqlite/base_msgs.c +++ b/plugins/persist-sqlite/base_msgs.c @@ -84,27 +84,29 @@ static char *properties_to_json(const mosquitto_property *properties) break; case MQTT_PROP_CORRELATION_DATA: - /* bin */ - void *binval = NULL; - mosquitto_property_read_binary(properties, propid, &binval, &len, false); - char *hexval = malloc(2*(size_t)len + 1); - if(!hexval){ + { + /* bin */ + void *binval = NULL; + mosquitto_property_read_binary(properties, propid, &binval, &len, false); + char *hexval = malloc(2*(size_t)len + 1); + if(!hexval){ + free(binval); + cJSON_Delete(array); + return NULL; + } + for(int i=0; i