markdown: reject inputs of 2^32 bytes or more instead of panicking - #32752
Merged
Claude / Claude Code Review
completed
Jun 26, 2026 in 18m 31s
Code review found 1 important issue
Found 3 candidates, confirmed 2. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 1 |
| 🟡 Nit | 1 |
| 🟣 Pre-existing | 0 |
| Severity | File:Line | Issue |
|---|---|---|
| 🔴 Important | src/runtime/api/MarkdownObject.rs:168 |
Bun.markdown.ansi still does a 6 GiB Vec::reserve before the new InputTooLarge check |
| 🟡 Nit | src/md/parser.rs:144-146 |
Stale doc comment on Error type alias omits new InputTooLarge variant |
Annotations
Check failure on line 168 in src/runtime/api/MarkdownObject.rs
claude / Claude Code Review
Bun.markdown.ansi still does a 6 GiB Vec::reserve before the new InputTooLarge check
The `.ansi()` path still does a ~6 GiB `Vec::reserve` *before* reaching the new `InputTooLarge` guard: `md::render_to_ansi` calls `AnsiRenderer::init` (which does `r.out.list.reserve(src_text.len() + src_text.len() / 2)`) and only then calls `render_with_renderer` → `Parser::init`. `Vec::reserve` aborts via `handle_alloc_error` on failure, so on hosts where the 4 GiB `Uint8Array` can be created but a 6 GiB malloc cannot (overcommit off, `RLIMIT_AS`, low-VA containers), `Bun.markdown.ansi(new Uin
Check warning on line 146 in src/md/parser.rs
claude / Claude Code Review
Stale doc comment on Error type alias omits new InputTooLarge variant
Nit: the doc comment on `pub type Error = ParserError;` a few lines up still describes the type as "the union of `{ OutOfMemory, JSError, JSTerminated }` with `{ StackOverflow }`", which is now incomplete with `InputTooLarge` added. Either add the new variant to the enumeration or drop the explicit list — the enum definition is right below it anyway.
Loading