is smaller than representation.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59200
138bc75d-0d04-0410-961f-
82ee72b054a4
+2002-11-17 Graham Stott <graham.stott@btinternet.com>
+
+ * real.c (real_to_decimal): Fix buffer overrun when buffer size
+ is smaller than representation.
+
2002-11-17 Kazu Hirata <kazu@cs.umass.edu>
* builtins.c: Fix formatting.
abort ();
}
+ /* Bound the number of digits printed by the size of the representation. */
+ max_digits = SIGNIFICAND_BITS * M_LOG10_2;
+ if (digits == 0 || digits > max_digits)
+ digits = max_digits;
+
/* Estimate the decimal exponent, and compute the length of the string it
will print as. Be conservative and add one to account for possible
overflow or rounding error. */
if (digits > max_digits)
digits = max_digits;
- /* Bound the number of digits printed by the size of the representation. */
- max_digits = SIGNIFICAND_BITS * M_LOG10_2;
- if (digits == 0 || digits > max_digits)
- digits = max_digits;
-
one = real_digit (1);
ten = ten_to_ptwo (0);