Index: net/websockets/websocket_deflater.cc |
diff --git a/net/websockets/websocket_deflater.cc b/net/websockets/websocket_deflater.cc |
index 9144c0116dc1ab7a13084c45c2ad5534069df4ae..71e95c27fa28810f96d275c68be41a8c98e95ce8 100644 |
--- a/net/websockets/websocket_deflater.cc |
+++ b/net/websockets/websocket_deflater.cc |
@@ -31,11 +31,19 @@ bool WebSocketDeflater::Initialize(int window_bits) { |
DCHECK_LE(8, window_bits); |
DCHECK_GE(15, window_bits); |
+ |
+ // Use a negative value to compress a raw deflate stream. Upgrade window_bits |
+ // = 8 (a 256-byte window) to 9 (a 512-byte window) because zlib is unable to |
+ // compress using a 256-byte window. This retains zlib's historical behavior |
+ // of silently increasing the window size in this case. See |
+ // https://crbug.com/691074. |
+ window_bits = -std::max(window_bits, 9); |
+ |
memset(stream_.get(), 0, sizeof(*stream_)); |
int result = deflateInit2(stream_.get(), |
Z_DEFAULT_COMPRESSION, |
Z_DEFLATED, |
- -window_bits, // Negative value for raw deflate |
+ window_bits, |
8, // default mem level |
Z_DEFAULT_STRATEGY); |
if (result != Z_OK) { |