From caa394d0feedef44f7e8b03749e2c22c4d9d2e40 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 17 Mar 2016 21:22:56 +0000 Subject: [PATCH] Return value of pthread_create is now checked. --- ChangeLog.txt | 1 + lib/thread_mosq.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 489d2999..1b784725 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -14,6 +14,7 @@ Broker: Client library: - Fix the case where a message received just before the keepalive timer expired would cause the client to miss the keepalive timer. +- Return value of pthread_create is now checked. Clients: - Handle some unchecked malloc() calls. Closes #1. diff --git a/lib/thread_mosq.c b/lib/thread_mosq.c index 6b83c7d6..dbb511df 100644 --- a/lib/thread_mosq.c +++ b/lib/thread_mosq.c @@ -31,8 +31,11 @@ int mosquitto_loop_start(struct mosquitto *mosq) if(!mosq || mosq->threaded) return MOSQ_ERR_INVAL; mosq->threaded = true; - pthread_create(&mosq->thread_id, NULL, _mosquitto_thread_main, mosq); - return MOSQ_ERR_SUCCESS; + if(!pthread_create(&mosq->thread_id, NULL, _mosquitto_thread_main, mosq)){ + return MOSQ_ERR_SUCCESS; + }else{ + return MOSQ_ERR_ERRNO; + } #else return MOSQ_ERR_NOT_SUPPORTED; #endif