Skip to content

Commit 835a542

Browse files
authored
Merge pull request #59 from Yangyuanxin/master
Fix memory leak when mqtt_yield_thread exits problem and delete unuse…
2 parents 22bbdb3 + 8eef1a5 commit 835a542

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mqttclient/mqttclient.c

100644100755
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,12 @@ static void mqtt_yield_thread(void *arg)
954954

955955
exit:
956956
thread_to_be_destoried = c->mqtt_thread;
957-
c->mqtt_thread = (platform_thread_t *)0;
958-
platform_thread_destroy(thread_to_be_destoried);
957+
if(NULL != thread_to_be_destoried)
958+
{
959+
platform_thread_destroy(thread_to_be_destoried);
960+
platform_memory_free(thread_to_be_destoried);
961+
thread_to_be_destoried = NULL;
962+
}
959963
}
960964

961965
static int mqtt_connect_with_results(mqtt_client_t* c)
@@ -1457,7 +1461,6 @@ int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg
14571461

14581462
int mqtt_list_subscribe_topic(mqtt_client_t* c)
14591463
{
1460-
int i = 0;
14611464
mqtt_list_t *curr, *next;
14621465
message_handlers_t *msg_handler;
14631466

0 commit comments

Comments
 (0)