diff --git a/client/sub_client_output.c b/client/sub_client_output.c index 7dc5af9a..9bef4c9b 100644 --- a/client/sub_client_output.c +++ b/client/sub_client_output.c @@ -196,6 +196,8 @@ static int json_print_properties(cJSON *root, const mosquitto_property *properti } cJSON_AddItemToObject(user_json, strname, tmp); free(strname); + strname = NULL; + strvalue = NULL; tmp = NULL; /* Don't add this to prop_json below */ break; } diff --git a/lib/property_mosq.c b/lib/property_mosq.c index 90c6d69f..0ace4472 100644 --- a/lib/property_mosq.c +++ b/lib/property_mosq.c @@ -1092,6 +1092,8 @@ const mosquitto_property *mosquitto_property_read_binary(const mosquitto_propert const mosquitto_property *p; if(!proplist || (value && !len) || (!value && len)) return NULL; + if(value) *value = NULL; + p = property__get_property(proplist, identifier, skip_first); if(!p) return NULL; if(p->identifier != MQTT_PROP_CORRELATION_DATA @@ -1146,6 +1148,9 @@ const mosquitto_property *mosquitto_property_read_string_pair(const mosquitto_pr const mosquitto_property *p; if(!proplist) return NULL; + if(name) *name = NULL; + if(value) *value = NULL; + p = property__get_property(proplist, identifier, skip_first); if(!p) return NULL; if(p->identifier != MQTT_PROP_USER_PROPERTY) return NULL;