diff --git a/src/read_handle_server.c b/src/read_handle_server.c index 9a2501a7..50ace2fc 100644 --- a/src/read_handle_server.c +++ b/src/read_handle_server.c @@ -441,12 +441,14 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context) found_context->sub_count = 0; for(i=0; isub_count; i++){ - leaf = context->subs[i]->subs; - while(leaf){ - if(leaf->context == found_context){ - leaf->context = context; + if(context->subs[i]){ + leaf = context->subs[i]->subs; + while(leaf){ + if(leaf->context == found_context){ + leaf->context = context; + } + leaf = leaf->next; } - leaf = leaf->next; } } }