Guard against use-after-free.

Coverity Scan 1431131, 1431135, 1431141.
pull/1522/merge
Roger A. Light 5 years ago
parent 84e4ba2c1e
commit 1b060bb064

@ -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;
}

@ -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;

Loading…
Cancel
Save