1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +00:00

Fixed bug in WebSocketStream partial fragment handler, where if fragment buffer size was 0, it would not realloc() correctly.

Also updated self-test to have inline documentation, as well as support for console debugging
This commit is contained in:
Bryan Roe
2022-06-28 20:36:32 -07:00
parent 8b8d2b95df
commit 043848a0f9
2 changed files with 121 additions and 14 deletions

View File

@@ -4373,6 +4373,7 @@ ILibTransport_DoneState ILibDuktape_httpStream_webSocket_EncodedWriteSink(ILibDu
if (state->WebSocketFragmentIndex + plen >= state->WebSocketFragmentBufferSize)
{
// Need to grow the buffer
if (state->WebSocketFragmentBufferSize == 0) { state->WebSocketFragmentBufferSize = 4096; }
state->WebSocketFragmentBufferSize = state->WebSocketFragmentBufferSize * 2;
if ((state->WebSocketFragmentBuffer = (char*)realloc(state->WebSocketFragmentBuffer, state->WebSocketFragmentBufferSize)) == NULL) { ILIBCRITICALEXIT(254); } // MS Static Analyser erroneously reports that this leaks the original memory block
}