Fix subscriptions sometimes being deleted.

Fix subscriptions being deleted when clients subscribed to a topic
beginning with a $ but that is not $SYS.

Thanks to David Woodward.
This commit is contained in:
Roger Light 2014-05-08 23:05:34 +01:00
parent ab15557931
commit e5cc63a89b
2 changed files with 7 additions and 3 deletions

View File

@ -5,8 +5,8 @@ Broker:
- Ensure that bridges verify certificates by default when using TLS.
- Fix possible crash when using pattern ACLs that do not include a %u and
clients that connect without a username.
- Fix subscriptions being deleted when clients subscribed to a topic beginning
with a $ but that is not $SYS.
Client library:
- Fix topic matching edge case.

View File

@ -377,7 +377,6 @@ int mqtt3_sub_add(struct mosquitto_db *db, struct mosquitto *context, const char
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
}
child->next = NULL;
child->topic = _mosquitto_strdup(tokens->topic);
if(!child->topic){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
@ -386,6 +385,11 @@ int mqtt3_sub_add(struct mosquitto_db *db, struct mosquitto *context, const char
child->subs = NULL;
child->children = NULL;
child->retained = NULL;
if(db->subs.children){
child->next = db->subs.children;
}else{
child->next = NULL;
}
db->subs.children = child;
rc = _sub_add(db, context, qos, child, tokens);