From 8bf87c9147b2b12d125a1a9bd9427be0581044ec Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Wed, 21 Nov 2018 19:09:42 +0100 Subject: [PATCH] Don't crash on Autobahn testing --- misc/main.cpp | 2 +- src/WebSocket.h | 4 +++- uSockets | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/main.cpp b/misc/main.cpp index dc068a1..bf2fa18 100644 --- a/misc/main.cpp +++ b/misc/main.cpp @@ -31,7 +31,7 @@ int main(int argc, char **argv) { std::cout << "WebSocket conntected to URL: " << req->getUrl() << std::endl; }, [](auto *ws, std::string_view message, uWS::OpCode opCode) { ws->send(message, opCode); - }).listen(3000, [](auto *token) { + }).listen(9001, [](auto *token) { if (token) { std::cout << "Listening on port " << 3000 << std::endl; } diff --git a/src/WebSocket.h b/src/WebSocket.h index 3d97b8e..1dfd1e3 100644 --- a/src/WebSocket.h +++ b/src/WebSocket.h @@ -20,13 +20,15 @@ public: // if corkAllocate(size) then corkFree(unused) // format the response - char buf[100]; + char *buf = (char *) malloc(message.length() + 100); int writeLength = WebSocketProtocol>::formatMessage(buf, message.data(), message.length(), opCode, message.length(), false); Super::write(buf, writeLength); + free(buf); + } // absolutely not public! diff --git a/uSockets b/uSockets index 70e1cc0..4a20739 160000 --- a/uSockets +++ b/uSockets @@ -1 +1 @@ -Subproject commit 70e1cc081f728c50347c28690b46fca58054a090 +Subproject commit 4a20739ca5d4124f0197031348cc91eaa4611fb7