diff --git a/lib/socks_mosq.c b/lib/socks_mosq.c index a9f0bbcd..bb651592 100644 --- a/lib/socks_mosq.c +++ b/lib/socks_mosq.c @@ -185,6 +185,7 @@ int socks5__send(struct mosquitto *mosq) }else{ slen = strlen(mosq->host); if(slen > UCHAR_MAX){ + mosquitto__free(packet); return MOSQ_ERR_NOMEM; } packet->packet_length = 7 + slen; diff --git a/src/handle_unsubscribe.c b/src/handle_unsubscribe.c index e9f89f8c..22728f9f 100644 --- a/src/handle_unsubscribe.c +++ b/src/handle_unsubscribe.c @@ -75,6 +75,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) while(context->in_packet.pos < context->in_packet.remaining_length){ sub = NULL; if(packet__read_string(&context->in_packet, &sub, &slen)){ + mosquitto__free(reason_codes); return 1; } @@ -83,6 +84,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) "Empty unsubscription string from %s, disconnecting.", context->id); mosquitto__free(sub); + mosquitto__free(reason_codes); return 1; } if(mosquitto_sub_topic_check(sub)){ @@ -90,6 +92,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) "Invalid unsubscription string from %s, disconnecting.", context->id); mosquitto__free(sub); + mosquitto__free(reason_codes); return 1; } @@ -97,7 +100,10 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) rc = sub__remove(db, context, sub, db->subs, &reason); log__printf(NULL, MOSQ_LOG_UNSUBSCRIBE, "%s %s", context->id, sub); mosquitto__free(sub); - if(rc) return rc; + if(rc){ + mosquitto__free(reason_codes); + return rc; + } reason_codes[reason_code_count] = reason; reason_code_count++; @@ -122,4 +128,3 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) mosquitto__free(reason_codes); return rc; } -