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

Fix heap corruption in Windows builds

This bug caused crashes in the Windows build of sbbs when using the ;spy
sysop command with MQTT enabled.

Memory that is allocated in one DLL (e.g. sbbs.dll) must be freed in that same
DLL (e.g. sbbs.dll, not mosquitto.dll).

mosquitto_message_free() here frees the msg pointer, but we didn't allocate
it in mosquitto.dll in the first place, so that's wrong. The proper mosquitto
function to use in this case is mosquitto_message_free_contents().
parent c8f58ded
No related branches found
No related tags found
No related merge requests found
......@@ -45,8 +45,10 @@ static void js_finalize_mqtt(JSContext* cx, JSObject* obj)
mosquitto_loop_stop(p->handle, /* force: */false);
mosquitto_destroy(p->handle);
}
while((msg = msgQueueRead(&p->q, /* timeout: */0)) != NULL)
mosquitto_message_free(&msg);
while((msg = msgQueueRead(&p->q, /* timeout: */0)) != NULL) {
mosquitto_message_free_contents(msg);
free(msg);
}
msgQueueFree(&p->q);
free(p);
......@@ -314,7 +316,8 @@ static JSBool js_read(JSContext* cx, uintN argc, jsval *arglist)
if(str != NULL)
JS_SET_RVAL(cx, arglist, STRING_TO_JSVAL(str));
}
mosquitto_message_free(&msg);
mosquitto_message_free_contents(msg);
free(msg);
}
JS_RESUMEREQUEST(cx, rc);
......
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