json_format(): Fix buffer overflow in float formatting
The ndigit argument to Gconvert() is the number of significant digits to format, not the size of the output buffer. D'oh.
This commit is contained in:
parent
f8b0043e22
commit
f52ad9a2e6
1 changed files with 1 additions and 1 deletions
|
|
@ -244,7 +244,7 @@ static void fujson_fmt(pTHX_ fujson_fmt_ctx *ctx, SV *val) {
|
|||
if (isinfnan(nv)) croak("unable to format floating point NaN or Inf as JSON");
|
||||
/* XXX: Cpanel::JSON::XS appears to always append a ".0" for round numbers, other modules do not. */
|
||||
/* XXX#2: This doesn't support quadmath. Makefile.PL checks for that */
|
||||
fustr_reserve(ctx->out, NV_DIG+1);
|
||||
fustr_reserve(ctx->out, NV_DIG+32);
|
||||
Gconvert(nv, NV_DIG, 0, ctx->out->cur);
|
||||
ctx->out->cur += strlen(ctx->out->cur);
|
||||
} else if (SvIOKp(val)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue