Skip to content

Commit

Permalink
Fix potential memory leaks.
Browse files Browse the repository at this point in the history
Closes #1773. Closes #1774. Thanks to Yingpei Zeng.
  • Loading branch information
ralight committed Aug 6, 2020
1 parent 618cd70 commit 94d0413
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.txt
Expand Up @@ -19,6 +19,7 @@ Broker:
than the generic "socket error".
- Don't try to start DLT logging if DLT unavailable, to avoid a long delay
when shutting down the broker. Closes #1735.
- Fix potential memory leaks. Closes #1773. Closes #1774.

Client library:
- Improved documentation around connect callback return codes. Close #1730.
Expand Down
5 changes: 4 additions & 1 deletion src/handle_publish.c
Expand Up @@ -109,7 +109,10 @@ int handle__publish(struct mosquitto_db *db, struct mosquitto *context)
/* Handle properties */
if(context->protocol == mosq_p_mqtt5){
rc = property__read_all(CMD_PUBLISH, &context->in_packet, &properties);
if(rc) return rc;
if(rc){
mosquitto__free(topic);
return rc;
}

p = properties;
p_prev = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/handle_subscribe.c
Expand Up @@ -119,6 +119,8 @@ int handle__subscribe(struct mosquitto_db *db, struct mosquitto *context)

retain_handling = (subscription_options & 0x30);
if(retain_handling == 0x30 || (subscription_options & 0xC0) != 0){
mosquitto__free(sub);
mosquitto__free(payload);
return MOSQ_ERR_PROTOCOL;
}
}
Expand Down

0 comments on commit 94d0413

Please sign in to comment.