diff options
author | 2022-10-17 07:24:12 -0700 | |
---|---|---|
committer | 2022-10-17 07:24:12 -0700 | |
commit | 41f9fd85f671f42093305cf7d4b64922ec83db4d (patch) | |
tree | 8bb4c0c883fabe178cda9aa149bd60a946725baa | |
parent | cdff2697efff88dd4059c41954f4bdd84bd3063c (diff) | |
download | bun-41f9fd85f671f42093305cf7d4b64922ec83db4d.tar.gz bun-41f9fd85f671f42093305cf7d4b64922ec83db4d.tar.zst bun-41f9fd85f671f42093305cf7d4b64922ec83db4d.zip |
Handle assertion faillure
-rw-r--r-- | src/http/websocket_http_client.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index 30ec92462..ac6d605bd 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -911,7 +911,6 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { pub fn consume(this: *WebSocket, data_: []const u8, left_in_fragment: usize, kind: Opcode, is_final: bool) usize { std.debug.assert(kind == .Text or kind == .Binary); std.debug.assert(data_.len <= left_in_fragment); - std.debug.assert(data_.len > 0); // did all the data fit in the buffer? // we can avoid copying & allocating a temporary buffer @@ -920,6 +919,9 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { return data_.len; } + // this must come after the above check + std.debug.assert(data_.len > 0); + var writable = this.receive_buffer.writableWithSize(data_.len) catch unreachable; @memcpy(writable.ptr, data_.ptr, data_.len); this.receive_buffer.update(data_.len); |