Fix assert failure when loading a persistence file.

If the file contains subscriptions with no client id.
This commit is contained in:
Roger A. Light
2023-11-15 23:08:04 +00:00
parent 28590fa383
commit fd097d5a0f
2 changed files with 16 additions and 2 deletions
+8
View File
@@ -1,3 +1,11 @@
2.0.19 - 2023-11-xx
===================
Broker:
- Fix assert failure when loading a persistence file that contains
subscriptions with no client id.
2.0.18 - 2023-09-18
===================
+8 -2
View File
@@ -547,8 +547,14 @@ static int persist__restore_sub(const char *client_id, const char *sub, uint8_t
{
struct mosquitto *context;
assert(client_id);
assert(sub);
if(!client_id){
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Persistence found a subscription with no client id, ignoring.");
return MOSQ_ERR_SUCCESS;
}
if(!sub){
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Persistence found a subscription with no topic filter, ignoring.");
return MOSQ_ERR_SUCCESS;
}
context = persist__find_or_add_context(client_id, 0);
if(!context) return 1;