diff options
author | 2021-10-16 20:23:06 -0700 | |
---|---|---|
committer | 2021-10-16 20:23:06 -0700 | |
commit | 54b313cc5ac7697fd08f696eb564bbc0ce0dd28b (patch) | |
tree | 64e038497592fff2687fb6ceda3e56672f8e60b6 | |
parent | 2461c11536799982b586fdd10af9d67ceba7303d (diff) | |
download | bun-54b313cc5ac7697fd08f696eb564bbc0ce0dd28b.tar.gz bun-54b313cc5ac7697fd08f696eb564bbc0ce0dd28b.tar.zst bun-54b313cc5ac7697fd08f696eb564bbc0ce0dd28b.zip |
Fix edgecase in Transfer-Encoding chunked
-rw-r--r-- | src/http_client.zig | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/http_client.zig b/src/http_client.zig index bc1a82406..65660c03b 100644 --- a/src/http_client.zig +++ b/src/http_client.zig @@ -520,10 +520,9 @@ pub fn processResponse(this: *HTTPClient, comptime is_https: bool, comptime repo var total_size = rsize; while (pret == -2) { - if (buffer.list.items[total_size..].len < @intCast(usize, decoder.bytes_left_in_chunk)) { - try buffer.inflate(total_size + @intCast(usize, decoder.bytes_left_in_chunk)); + if (buffer.list.items[total_size..].len < @intCast(usize, decoder.bytes_left_in_chunk) or buffer.list.items[total_size..].len < 512) { + try buffer.inflate(std.math.max(total_size * 2, 1024)); buffer.list.expandToCapacity(); - var slice = buffer.list.items[total_size..]; } rret = try client.read(buffer.list.items[total_size..]); |