Fix possible null dereferences.

pull/1588/head
Roger A. Light 6 years ago
parent 05ec02b3f3
commit 5528dde56a

@ -498,10 +498,11 @@ int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int li
}
context = NULL;
HASH_FIND(hh_sock, db->contexts_by_sock, &(ev.data.fd), sizeof(mosq_sock_t), context);
if(!context) {
if(context){
context->events = EPOLLIN;
}else{
log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll accepting: no context");
}
context->events = EPOLLIN;
}
}
break;

@ -216,8 +216,8 @@ static struct sub__token *sub__topic_append(struct sub__token **tail, struct sub
static int sub__topic_tokenise(const char *subtopic, struct sub__token **topics)
{
struct sub__token *new_topic, *tail = NULL;
int len;
int start, stop, tlen;
size_t len;
size_t start, stop, tlen;
int i;
char *topic;
int count = 0;
@ -225,13 +225,16 @@ static int sub__topic_tokenise(const char *subtopic, struct sub__token **topics)
assert(subtopic);
assert(topics);
len = strlen(subtopic);
if(len == 0){
return 1;
}
if(subtopic[0] != '$'){
new_topic = sub__topic_append(&tail, topics, "");
if(!new_topic) goto cleanup;
}
len = strlen(subtopic);
if(subtopic[0] == '/'){
new_topic = sub__topic_append(&tail, topics, "");
if(!new_topic) goto cleanup;
@ -268,7 +271,11 @@ static int sub__topic_tokenise(const char *subtopic, struct sub__token **topics)
goto cleanup;
}
return MOSQ_ERR_SUCCESS;
if(*topics != NULL){
return MOSQ_ERR_SUCCESS;
}else{
return 1;
}
cleanup:
tail = *topics;

Loading…
Cancel
Save