PR libgfortran/32554
* io/write.c (output_float): Set edigits to a fixed size, avoiding
variation in field width calculation and eliminate buffer overrun.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126173
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-07-01 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/32554
+ * io/write.c (output_float): Set edigits to a fixed size, avoiding
+ variation in field width calculation and eliminate buffer overrun.
+
2007-07-01 Janne Blomqvist <jb@gcc.gnu.org>
* runtime/memory.c (internal_realloc): Use index_type for size
int nblanks;
int i;
sign_t sign;
- double abslog;
ft = f->format;
w = f->u.real.w;
value = value + 0.5;
}
- /* Printf always prints at least two exponent digits. */
- if (value == 0)
- edigits = 2;
- else
- {
-#if defined(HAVE_GFC_REAL_10) || defined(HAVE_GFC_REAL_16)
- abslog = fabs((double) log10l(value));
-#else
- abslog = fabs(log10(value));
-#endif
- if (abslog < 100)
- edigits = 2;
- else
- edigits = 1 + (int) log10(abslog);
- }
+ /* printf pads blanks for us on the exponent so we just need it big enough
+ to handle the largest number of exponent digits expected. */
+ edigits=4;
if (ft == FMT_F || ft == FMT_EN
|| ((ft == FMT_D || ft == FMT_E) && dtp->u.p.scale_factor != 0))