proofs.rs

String builder panics on 256 consecutive quotes

String builder panics on 256 consecutive quotes

Found in Report #39 v1 · Updated 2026-11-25 09:05 UTC

Description

In toml_write 0.1.2, TomlStringBuilder::new panics on a valid string containing 256 consecutive double quotes when overflow checks are enabled. A run of apostrophes also triggers the panic, as does converting the affected string with ToTomlValue.

Steps to Reproduce

With toml_write = "=0.1.2", run this in the default dev profile:

use toml_write::TomlStringBuilder;

fn main() {
    let input = "\"".repeat(256);
    let _ = TomlStringBuilder::new(&input);
}
Expected Behavior

The builder accepts the valid string so it can be encoded as a TOML string.

Actual Behavior

The call panics with attempt to add with overflow in ValueMetrics::calculate.

Environment

toml_write 0.1.2, default features, Rust 1.94.1, default dev profile. The tested default release profile did not panic for this input.

Additional Context

Related: toml-rs/toml#1188 reports the same counter overflow in a later toml_writer release.

Change history
  1. v1 · created · 2026-11-25 09:05 UTC
    {
      "title": "String builder panics on 256 consecutive quotes",
      "body": "## Description\n\nIn `toml_write` 0.1.2, `TomlStringBuilder::new` panics on a valid string containing 256 consecutive double quotes when overflow checks are enabled. A run of apostrophes also triggers the panic, as does converting the affected string with `ToTomlValue`.\n\n## Steps to Reproduce\n\nWith `toml_write = \"=0.1.2\"`, run this in the default dev profile:\n\n```rust\nuse toml_write::TomlStringBuilder;\n\nfn main() {\n    let input = \"\\\"\".repeat(256);\n    let _ = TomlStringBuilder::new(&input);\n}\n```\n\n## Expected Behavior\n\nThe builder accepts the valid string so it can be encoded as a TOML string.\n\n## Actual Behavior\n\nThe call panics with `attempt to add with overflow` in `ValueMetrics::calculate`.\n\n## Environment\n\n`toml_write` 0.1.2, default features, Rust 1.94.1, default dev profile. The tested default release profile did not panic for this input.\n\n## Additional Context\n\nRelated: [toml-rs/toml#1188](https://github.com/toml-rs/toml/issues/1188) reports the same counter overflow in a later `toml_writer` release.",
      "validity": "reported",
      "upstream_status": "not_reported"
    }

Read and join the discussion on the report →