)]}'
{
  "commit": "297637bc0a0f00dc504dbc1a47ebdaa577f8ae19",
  "tree": "d0e36c5d0cd719c1c8d53ade4205a7292449edc2",
  "parents": [
    "24b5e7a8b27f42fa16b96fc70aade9106cf7102f"
  ],
  "author": {
    "name": "Milo Yip",
    "email": "miloyip@gmail.com",
    "time": "Thu Oct 29 09:30:27 2026"
  },
  "committer": {
    "name": "Milo Yip",
    "email": "miloyip@gmail.com",
    "time": "Tue Nov 03 22:50:56 2026"
  },
  "message": "Fix integer overflow in Writer::WriteString for long strings\n\nThis fix is attributed to @afonsojanu\r\n\r\nFixes #2348, and the same root cause reported separately in #2336.\r\n\r\nWriteString computes the stack reservation as 2 + length * 6 (or * 12 for the non-Unicode-target case), where length is a SizeType. With the default SizeType (unsigned, 32-bit), that multiplication overflows for strings around 716 million characters and up, so PutReserve ends up reserving far less space than the writer actually needs. Once writing continues past the undersized buffer, that\u0027s either a hard assertion failure in Stack::PushUnsafe in debug builds (exactly the crash reported in #2348), or plain memory corruption in release builds.\r\n\r\nWidening length to size_t before the multiplication fixes it: on 64-bit platforms the multiplication now happens at 64 bits and can\u0027t wrap around for any length that actually fits in a SizeType to begin with.\r\n\r\nVerified with a small standalone program writing an 800,000,000-character string through Writer\u003cStringBuffer\u003e: reliably hits the reported assertion on unmodified master, and completes correctly with the fix (produces a StringBuffer of the exact expected size). I didn\u0027t add this as an automated unit test in this PR, since a real repro needs close to a gigabyte of memory and I wasn\u0027t sure that\u0027s a good tradeoff for the test suite to run on every CI job — happy to add one if you\u0027d rather have it. Ran the existing writer, prettywriter, stringbuffer, and document unit tests (63 cases) against the fix, all pass unchanged.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "632e02ce74a555919df6c19cc961fdeb74f8431b",
      "old_mode": 33188,
      "old_path": "include/rapidjson/writer.h",
      "new_id": "89001bd960a418587a68fa69474ff03230739819",
      "new_mode": 33188,
      "new_path": "include/rapidjson/writer.h"
    }
  ]
}
