Fix some property leaks.

pull/1239/head
Roger A. Light 7 years ago
parent fe854d3a64
commit 8097ec24f9

@ -102,7 +102,6 @@ struct mosquitto *context__init(struct mosquitto_db *db, mosq_sock_t sock)
void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool do_free)
{
struct mosquitto__packet *packet;
struct mosquitto_client_msg *msg, *next;
#ifdef WITH_BRIDGE
int i;
#endif
@ -179,24 +178,7 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d
mosquitto__free(packet);
}
if(do_free || context->clean_start){
msg = context->inflight_msgs;
while(msg){
next = msg->next;
db__msg_store_deref(db, &msg->store);
mosquitto__free(msg);
msg = next;
}
context->inflight_msgs = NULL;
context->last_inflight_msg = NULL;
msg = context->queued_msgs;
while(msg){
next = msg->next;
db__msg_store_deref(db, &msg->store);
mosquitto__free(msg);
msg = next;
}
context->queued_msgs = NULL;
context->last_queued_msg = NULL;
db__messages_delete(db, context);
}
#if defined(WITH_BROKER) && defined(__GLIBC__) && defined(WITH_ADNS)
if(context->adns){

@ -569,6 +569,7 @@ int db__messages_delete(struct mosquitto_db *db, struct mosquitto *context)
while(tail){
db__msg_store_deref(db, &tail->store);
next = tail->next;
mosquitto_property_free_all(&tail->properties);
mosquitto__free(tail);
tail = next;
}
@ -579,6 +580,7 @@ int db__messages_delete(struct mosquitto_db *db, struct mosquitto *context)
while(tail){
db__msg_store_deref(db, &tail->store);
next = tail->next;
mosquitto_property_free_all(&tail->properties);
mosquitto__free(tail);
tail = next;
}

@ -161,16 +161,21 @@ int handle__publish(struct mosquitto_db *db, struct mosquitto *context)
mosquitto_property_free_all(&properties);
if(topic_alias == 0 || topic_alias > context->listener->max_topic_alias){
mosquitto__free(topic);
send__disconnect(context, MQTT_RC_TOPIC_ALIAS_INVALID, NULL);
return MOSQ_ERR_PROTOCOL;
}else if(topic_alias > 0){
if(topic){
rc = alias__add(context, topic, topic_alias);
if(rc) return rc;
if(rc){
mosquitto__free(topic);
return rc;
}
}else{
rc = alias__find(context, &topic, topic_alias);
if(rc){
send__disconnect(context, MQTT_RC_TOPIC_ALIAS_INVALID, NULL);
mosquitto__free(topic);
return rc;
}
}

Loading…
Cancel
Save