summaryrefslogtreecommitdiff
path: root/ext/json/vendor/fpconv.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-05-23 09:28:56 +0200
committerHiroshi SHIBATA <[email protected]>2025-05-26 11:46:12 +0900
commitf171a263f76d6505b891f848bc5393ebbb973be3 (patch)
tree449db66c4f2c00e83aa3c43b8f7d3e7076689065 /ext/json/vendor/fpconv.c
parentaa00a2d07bf56fc5def659e06104eb3173803ca7 (diff)
[ruby/json] Fix: generate_json_float to reserve enough memory for large negative floats.
Fix: https://github.com/ruby/json/issues/807 Since https://github.com/ruby/json/pull/800, `fpconv_dtoa` can actually generate up to 28 chars. https://github.com/ruby/json/commit/d73ae93d3c
Diffstat (limited to 'ext/json/vendor/fpconv.c')
-rw-r--r--ext/json/vendor/fpconv.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/json/vendor/fpconv.c b/ext/json/vendor/fpconv.c
index 1bbca28739..75efd46f11 100644
--- a/ext/json/vendor/fpconv.c
+++ b/ext/json/vendor/fpconv.c
@@ -432,8 +432,8 @@ static int filter_special(double fp, char* dest)
*
* Input:
* fp -> the double to convert, dest -> destination buffer.
- * The generated string will never be longer than 24 characters.
- * Make sure to pass a pointer to at least 24 bytes of memory.
+ * The generated string will never be longer than 28 characters.
+ * Make sure to pass a pointer to at least 28 bytes of memory.
* The emitted string will not be null terminated.
*
* Output:
@@ -443,7 +443,7 @@ static int filter_special(double fp, char* dest)
*
* void print(double d)
* {
- * char buf[24 + 1] // plus null terminator
+ * char buf[28 + 1] // plus null terminator
* int str_len = fpconv_dtoa(d, buf);
*
* buf[str_len] = '\0';
@@ -451,7 +451,7 @@ static int filter_special(double fp, char* dest)
* }
*
*/
-static int fpconv_dtoa(double d, char dest[24])
+static int fpconv_dtoa(double d, char dest[28])
{
char digits[18];