diff --git a/src/WebSocketProtocol.h b/src/WebSocketProtocol.h index afae2bb7f..38f6a6b2f 100644 --- a/src/WebSocketProtocol.h +++ b/src/WebSocketProtocol.h @@ -402,7 +402,12 @@ struct WIN32_EXPORT WebSocketProtocol { /* No need to unmask if mask is 0 */ uint32_t nullmask = 0; if (!memcmp(wState->mask, &nullmask, sizeof(uint32_t))) { - unmaskAll(src, wState->mask); + if /*constexpr*/ (LIBUS_RECV_BUFFER_LENGTH == length) { + unmaskAll(src, wState->mask); + } else { + // Slow path + unmaskInplace(src, src + ((length >> 2) + 1) * 4, wState->mask); + } } }