Skip to content

Commit 121667b

Browse files
committed
allocate only as much bytes as needed
1 parent af35e24 commit 121667b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/websocket.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ WebSocketParser::getNextFrame() {
153153
char* pos = strstr(mData, "\r\n\r\n");
154154

155155
if (pos) {
156-
char* data = (char*) malloc(mLength);
156+
char* data = (char*) malloc(pos - mData);
157157
memcpy(data, mData, pos - mData);
158158

159159
WebSocketFrame* frame = new WebSocketFrame(0, UNKNOWN);

0 commit comments

Comments
 (0)