robobun
576b21f2ff
fix(test): prevent integer overflow in pretty_format writeIndent ( #23843 )
...
## Summary
Fixes a panic that occurred when formatting deeply nested objects with
many properties in test output.
## Problem
The `writeIndent()` function in `pretty_format.zig:648` performed
`written * 2` which triggered integer overflow checking in debug builds
when formatting complex nested structures.
**Original crash:**
```
panic: integer overflow
writeIndent at bun.js/test/pretty_format.zig:648
```
**Platform:** Windows x86_64_baseline, Bun v1.3.0
## Solution
Changed from:
```zig
try writer.writeAll(buf[0 .. written * 2]);
```
To:
```zig
const byte_count = @min(buf.len, written *% 2);
try writer.writeAll(buf[0..byte_count]);
```
- Used wrapping multiplication (`*%`) to prevent overflow panic
- Added bounds checking with `@min(buf.len, ...)` for safety
- Maintains correct behavior while preventing crashes
## Test
Added regression test at
`test/js/bun/test/pretty-format-overflow.test.ts` that:
- Creates deeply nested objects (500 levels with 50 properties each)
- Verifies no panic/overflow/crash occurs when formatting
- Uses exact configuration that triggered the original crash
## Verification
- ✅ Test passes with the fix
- ✅ Test would crash without the fix (in debug builds)
- ✅ No changes to behavior, only safety improvement
Co-authored-by: Claude Bot <claude-bot@bun.sh >
Co-authored-by: Claude <noreply@anthropic.com >
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-10-19 21:20:56 -07:00
..
2025-10-03 17:10:28 -07:00
2025-07-22 17:51:38 -07:00
2025-10-06 06:40:15 -07:00
2025-10-18 20:49:57 -07:00
2025-08-11 20:19:34 -07:00
2025-10-18 17:04:47 -07:00
2025-07-22 17:51:38 -07:00
2025-10-19 21:20:56 -07:00
2025-10-18 20:49:57 -07:00
2025-10-15 17:38:02 -07:00
2025-10-18 18:14:01 -07:00
2025-10-10 03:48:04 -07:00
2025-09-14 04:14:48 -07:00
2025-10-02 14:11:29 -07:00
2025-10-18 17:04:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-10-11 19:21:14 -07:00
2025-10-14 19:46:47 -07:00
2025-10-10 22:49:45 -07:00
2025-10-13 11:19:17 -07:00
2025-10-05 17:23:59 -07:00
2025-10-09 19:04:41 -07:00
2025-10-14 19:46:47 -07:00
2025-07-21 13:26:47 -07:00
2025-10-10 03:48:04 -07:00
2025-10-03 17:10:28 -07:00
2025-10-14 19:48:25 -07:00
2025-10-03 17:10:28 -07:00
2025-10-08 18:00:38 -07:00
2025-10-03 16:13:06 -07:00
2025-10-14 20:51:34 -07:00
2025-10-14 19:48:25 -07:00
2025-09-09 20:41:10 -07:00
2025-10-08 18:00:38 -07:00
2025-10-14 17:43:38 -07:00
2025-10-06 19:47:24 -07:00
2025-10-18 17:04:47 -07:00
2025-10-10 03:48:04 -07:00
2025-10-16 21:52:22 -04:00
2025-07-21 13:26:47 -07:00
2025-09-26 13:47:24 -07:00
2025-10-18 17:04:47 -07:00
2025-06-04 19:41:26 -07:00
2025-10-12 11:29:48 -07:00
2025-10-04 02:17:55 -07:00
2025-09-26 13:47:24 -07:00
2025-09-27 00:45:29 -07:00
2025-05-14 18:42:42 -07:00
2025-07-29 19:35:46 -07:00
2025-10-18 20:49:57 -07:00
2025-07-22 17:51:38 -07:00
2025-09-30 05:26:32 -07:00
2025-07-22 17:51:38 -07:00
2025-09-03 18:57:39 -07:00
2025-07-22 17:51:38 -07:00
2025-07-20 23:04:17 -07:00
2025-10-14 19:48:25 -07:00
2025-10-14 19:48:25 -07:00
2025-10-06 19:48:16 -07:00
2025-06-12 14:20:28 -07:00
2025-09-18 19:37:24 -07:00
2025-07-21 13:26:47 -07:00
2025-10-14 16:33:30 -07:00
2025-10-15 17:38:02 -07:00
2025-09-26 15:19:45 -07:00
2025-10-08 18:00:38 -07:00
2025-07-31 00:56:50 -07:00
2025-08-11 20:19:34 -07:00
2025-10-12 14:00:11 -07:00
2025-07-22 17:51:38 -07:00
2025-07-21 13:26:47 -07:00
2025-09-26 22:21:00 -07:00
2025-09-19 02:06:02 -07:00
2025-07-21 13:26:47 -07:00
2025-10-14 19:48:25 -07:00
2025-07-28 00:13:17 -07:00
2025-08-22 23:04:58 -07:00
2025-05-08 23:22:16 -07:00
2025-05-08 23:22:16 -07:00
2025-08-14 18:03:26 -07:00
2025-10-07 12:07:29 -07:00
2025-05-08 23:22:16 -07:00
2025-10-10 03:48:04 -07:00
2025-10-14 16:33:30 -07:00
2025-08-23 06:55:30 -07:00
2025-10-04 00:31:47 -07:00
2025-09-24 00:47:52 -07:00
2025-10-02 14:11:29 -07:00
2025-09-19 02:38:38 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-09-09 20:41:10 -07:00
2025-10-06 05:39:22 -07:00
2025-07-09 00:19:57 -07:00
2025-10-14 20:51:34 -07:00
2025-07-22 17:51:38 -07:00
2025-08-23 06:55:30 -07:00
2025-07-22 17:51:38 -07:00
2025-10-10 03:48:04 -07:00
2025-10-15 14:31:27 -07:00
2025-10-18 20:49:57 -07:00
2025-09-11 23:29:53 -07:00
2025-10-14 20:51:34 -07:00
2025-07-22 17:51:38 -07:00
2025-10-04 01:56:42 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-07-22 17:51:38 -07:00
2025-10-18 18:14:01 -07:00
2025-10-03 17:10:28 -07:00
2025-07-22 17:51:38 -07:00
2025-09-14 04:14:48 -07:00
2025-10-14 20:51:34 -07:00
2025-10-03 17:13:22 -07:00
2025-07-22 17:51:38 -07:00
2025-09-12 23:59:24 -07:00
2025-09-30 00:10:15 -07:00
2025-09-25 18:03:27 -07:00
2025-07-21 13:26:47 -07:00
2025-09-09 20:41:10 -07:00
2025-07-21 13:26:47 -07:00
2025-09-26 15:15:58 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-09-26 22:21:00 -07:00
2025-09-26 22:21:00 -07:00
2025-09-03 15:40:44 -07:00
2025-09-22 19:28:26 -07:00
2025-07-21 13:26:47 -07:00
2025-10-11 08:23:25 -07:00
2025-07-21 13:26:47 -07:00
2025-10-10 03:48:04 -07:00
2025-07-13 04:27:43 -07:00
2025-07-13 04:27:43 -07:00
2025-07-13 04:27:43 -07:00
2025-10-04 04:57:29 -07:00
2025-10-14 16:33:30 -07:00
2025-07-21 13:26:47 -07:00
2025-09-03 15:40:44 -07:00
2025-07-25 12:38:06 -07:00
2025-07-21 13:26:47 -07:00
2025-09-19 02:06:02 -07:00
2025-10-03 17:10:28 -07:00
2025-07-21 13:26:47 -07:00
2025-10-14 19:48:25 -07:00
2025-07-21 13:26:47 -07:00
2025-10-03 02:38:55 -07:00
2025-10-14 16:33:30 -07:00
2025-07-22 17:51:38 -07:00
2025-08-11 20:19:34 -07:00
2025-07-20 23:04:17 -07:00
2025-08-23 06:55:30 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-07-21 13:26:47 -07:00
2025-09-03 18:57:39 -07:00