Skip to content

Commit 42af296

Browse files
committed
Fixed memory buffer allocation
1 parent eb2af8a commit 42af296

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

include/internal/WebSocketContext.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <zlib.h>
99
namespace SL {
1010
namespace WS_LITE {
11-
const size_t LARGE_BUFFER_SIZE = 4 * 1024 * 1024; // 4 MB temp buffer
11+
const size_t LARGE_BUFFER_SIZE = 1024 * 1024; // 1 MB temp buffer
1212
class IWebSocket;
1313
struct HttpHeader;
1414
struct WSMessage;
@@ -27,10 +27,14 @@ namespace WS_LITE {
2727
public:
2828
WebSocketContext()
2929
{
30-
TempInflateBuffer = std::make_unique<unsigned char[]>(MaxPayload);
30+
TempInflateBuffer = std::make_unique<unsigned char[]>(LARGE_BUFFER_SIZE);
3131
inflateInit2(&InflationStream, -MAX_WBITS);
3232
}
33-
~WebSocketContext() { inflateEnd(&InflationStream); }
33+
~WebSocketContext()
34+
{
35+
inflateEnd(&InflationStream);
36+
free(InflateBuffer);
37+
}
3438
auto beginInflate()
3539
{
3640
InflateBufferSize = 0;

0 commit comments

Comments
 (0)