Skip to content
Snippets Groups Projects
Commit dec45548 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix memory leak on destruction when all received messages were not read

parent ab4eca0e
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4347 passed
......@@ -35,6 +35,7 @@ typedef struct
static void js_finalize_mqtt(JSContext* cx, JSObject* obj)
{
private_t* p;
struct mosquitto_message* msg;
if((p = (private_t*)JS_GetPrivate(cx,obj)) == NULL)
return;
......@@ -44,6 +45,8 @@ static void js_finalize_mqtt(JSContext* cx, JSObject* obj)
mosquitto_loop_stop(p->handle, /* force: */true);
mosquitto_destroy(p->handle);
}
while((msg = msgQueueRead(&p->q, /* timeout: */0)) != NULL)
mosquitto_message_free(&msg);
msgQueueFree(&p->q);
free(p);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment