diff options
Diffstat (limited to 'contrib/seg/seg.c')
-rw-r--r-- | contrib/seg/seg.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 4a8e2be3290..91b8a796004 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -927,9 +927,13 @@ restore(char *result, float val, int n) /* * Put a cap on the number of significant digits to avoid garbage in the - * output and ensure we don't overrun the result buffer. + * output and ensure we don't overrun the result buffer. (n should not be + * negative, but check to protect ourselves against corrupted data.) */ - n = Min(n, FLT_DIG); + if (n <= 0) + n = FLT_DIG; + else + n = Min(n, FLT_DIG); /* remember the sign */ sign = (val < 0 ? 1 : 0); |