I'm trying to write a small plugin for X-Plane, to create a simple websocket server with libwebsocket. I'm able to connect to the websocket from Google Chrome, however, when I send data to the server, X-Plane immediately crashes.
I'm pretty certain the following code is causing the problem:
unsigned char *buf = (unsigned char*) malloc(LWS_SEND_BUFFER_PRE_PADDING + 13 + LWS_SEND_BUFFER_POST_PADDING);
buf = (unsigned char*) "Hello World!";
libwebsocket_write(wsi, buf, len, LWS_WRITE_TEXT);
free(buf);
I'm not a C programmer / specialist at all, but does the above seem to have a problem at all?
I've posted the full source on Gist: https://gist.github.com/josefvanniekerk/868432986f2f963a5583