From d735a1579d51b6af1fc47e058133ec202fba9d13 Mon Sep 17 00:00:00 2001
From: Marcus Comstedt <marcus@mc.pp.se>
Date: Sun, 31 May 2020 19:47:19 +0200
Subject: [PATCH] JSON: Fix floating point literals with long-double-precision

---
 src/post_modules/JSON/json_number.c     | 4 ++++
 src/post_modules/JSON/rl/json_number.rl | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/src/post_modules/JSON/json_number.c b/src/post_modules/JSON/json_number.c
index 111f30e669..cf5f047db9 100644
--- a/src/post_modules/JSON/json_number.c
+++ b/src/post_modules/JSON/json_number.c
@@ -202,7 +202,11 @@ case 10:
     if (cs >= JSON_number_first_final) {
 	if (!(state->flags&JSON_VALIDATE)) {
 	    if (d == 1) {
+#if SIZEOF_FLOAT_TYPE > SIZEOF_DOUBLE
+		push_float((FLOAT_TYPE)STRTOLD_PCHARP(ADD_PCHARP(str, i), NULL));
+#else
 		push_float((FLOAT_TYPE)STRTOD_PCHARP(ADD_PCHARP(str, i), NULL));
+#endif
 	    } else {
 		pcharp_to_svalue_inumber(Pike_sp++, ADD_PCHARP(str, i), NULL, 10, p - i);
 	    }
diff --git a/src/post_modules/JSON/rl/json_number.rl b/src/post_modules/JSON/rl/json_number.rl
index 0f79b8fe73..a8c247a534 100644
--- a/src/post_modules/JSON/rl/json_number.rl
+++ b/src/post_modules/JSON/rl/json_number.rl
@@ -32,7 +32,11 @@ static ptrdiff_t _parse_JSON_number(PCHARP str, ptrdiff_t p, ptrdiff_t pe, struc
     if (cs >= JSON_number_first_final) {
 	if (!(state->flags&JSON_VALIDATE)) {
 	    if (d == 1) {
+#if SIZEOF_FLOAT_TYPE > SIZEOF_DOUBLE
+		push_float((FLOAT_TYPE)STRTOLD_PCHARP(ADD_PCHARP(str, i), NULL));
+#else
 		push_float((FLOAT_TYPE)STRTOD_PCHARP(ADD_PCHARP(str, i), NULL));
+#endif
 	    } else {
 		pcharp_to_svalue_inumber(Pike_sp++, ADD_PCHARP(str, i), NULL, 10, p - i);
 	    }
-- 
GitLab