about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/efgcvt_r.c4
-rw-r--r--misc/tst-efgcvt.c1
2 files changed, 3 insertions, 2 deletions
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index 167bd7a809..944fe4cc98 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -191,8 +191,8 @@ APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
       *sign = isfinite (value) ? signbit (value) != 0 : 0;
     }
   else
-    if (APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit - 1, decpt, sign,
-				      buf, len))
+    if (APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
+				      decpt, sign, buf, len))
       return -1;
 
   *decpt += exponent;
diff --git a/misc/tst-efgcvt.c b/misc/tst-efgcvt.c
index cfbaa21cb1..d0ebd0d863 100644
--- a/misc/tst-efgcvt.c
+++ b/misc/tst-efgcvt.c
@@ -56,6 +56,7 @@ static testcase ecvt_tests[] =
   { 123.01, -4, 3, "" },
   { 126.71, -4, 3, "" },
   { 0.0, 4, 1, "0000" },
+  { 92.0, 16, 2, "920000000000000" },
   /* -1.0 is end marker.  */
   { -1.0, 0, 0, "" }
 };