From 7a2dd634cbe1870f50756932e7cc29e827446350 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 20 Oct 2014 18:01:45 +0100 Subject: [PATCH] Protect against possible NULL dereference after unsubscribing. --- src/read_handle_server.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; } } }