Skip to content

Commit 59e165c

Browse files
committed
Optimize code
1 parent af180f5 commit 59e165c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/protocol/websocket.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ int dispatch_frame(const Protocol *proto, Socket *_socket, const RecvData *rdata
320320
dispatch_data.info.len = 0;
321321
} else {
322322
offset = ws.header.MASK ? SW_WEBSOCKET_HEADER_LEN + SW_WEBSOCKET_MASK_LEN : SW_WEBSOCKET_HEADER_LEN;
323-
dispatch_data.data = data + offset;
324323
dispatch_data.info.len = length - offset;
324+
dispatch_data.data = dispatch_data.info.len == 0 ? nullptr : data + offset;
325325
}
326326
dispatch_data.info.ext_flags = get_ext_flags(ws.header.OPCODE, get_flags(&ws));
327327
Server::dispatch_task(proto, _socket, &dispatch_data);

0 commit comments

Comments
 (0)