Fix benign off-by-one

Previously we always reserved one more byte than necessary in the
sprintf output string.
This commit is contained in:
John Hawthorn 2024-10-23 22:32:55 -07:00
parent 1f6dd9071c
commit c8c94bfb1e
Notes: git 2024-11-09 01:39:37 +00:00

View File

@ -67,7 +67,8 @@ sign_bits(int base, const char *p)
#define CHECK(l) do {\
int cr = ENC_CODERANGE(result);\
while ((l) >= bsiz - blen) {\
RUBY_ASSERT(bsiz >= blen); \
while ((l) > bsiz - blen) {\
bsiz*=2;\
if (bsiz<0) rb_raise(rb_eArgError, "too big specifier");\
}\