AntiPattern
Miscalculated Buffer Lengths
miscalculated-buffer-lengths
Buffer length fields get miscomputed during multi-step conversions (two-pass escaping and realloc-after-E2BIG), causing remaining-space calculations to be wrong and assertions to only catch it in debug builds, leading to overreads/size confusion.