| ... | ... | @@ -1156,7 +1156,7 @@ pub fn readToEndAllocOptions( |
| 1156 | 1156 | // The file size returned by stat is used as hint to set the buffer |
| 1157 | 1157 | // size. If the reported size is zero, as it happens on Linux for files |
| 1158 | 1158 | // in /proc, a small buffer is allocated instead. |
| 1159 | | const initial_cap = (if (size > 0) size else 1024) + @intFromBool(optional_sentinel != null); |
| 1159 | const initial_cap = @min((if (size > 0) size else 1024), max_bytes) + @intFromBool(optional_sentinel != null); |
| 1160 | 1160 | var array_list = try std.ArrayListAligned(u8, alignment).initCapacity(allocator, initial_cap); |
| 1161 | 1161 | defer array_list.deinit(); |
| 1162 | 1162 | |