Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/Simple-WebSocket-Server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormbroshi <michael.broshi@mathworks.com>2019-04-09 22:46:13 +0300
committermbroshi <michael.broshi@mathworks.com>2019-04-09 22:46:13 +0300
commit5949e758ef896013e7068986a501dc50a7dfa829 (patch)
tree29491d48cde570eb9609fc2bdafec9f587dcdf0c
parent24962ff97c674b48decde2821b7cbe0fdba631b8 (diff)
Allocate correct amount of additional capacity on buffer
-rw-r--r--client_ws.hpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/client_ws.hpp b/client_ws.hpp
index 948b3d4..29a1cbb 100644
--- a/client_ws.hpp
+++ b/client_ws.hpp
@@ -234,8 +234,9 @@ namespace SimpleWeb {
mask[c] = static_cast<unsigned char>(dist(rd));
std::size_t length = out_message->size();
-
- auto out_header_and_message = std::make_shared<OutMessage>(length + 12); // at most 12 header bytes added
+
+ std::size_t max_additional_bytes = 14; // ws protocol adds at most 14 bytes
+ auto out_header_and_message = std::make_shared<OutMessage>(length + max_additional_bytes);
out_header_and_message->put(static_cast<char>(fin_rsv_opcode));
// Masked (first length byte>=128)