From fdef6a73f1fe135f4186c6beaddf26d088f9f992 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Mon, 4 Dec 2017 03:51:28 +0000 Subject: [PATCH] backport: re PR libfortran/83168 (FAIL: gfortran.dg/fmt_f0_2.f90 with a sanitized libgfortran) 2017-12-03 Jerry DeLisle Backport from trunk PR libgfortran/83168 * io/write.c (select_string): Bump size by one to avoid overrun. From-SVN: r255373 --- libgfortran/ChangeLog | 7 +++++++ libgfortran/io/write.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 3e8173913a0..986b2b0a31e 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2017-12-03 Jerry DeLisle + + Backport from trunk + PR libgfortran/83168 + * io/write.c (select_string): Bump size by one to avoid + overrun. + 2017-12-03 Jerry DeLisle Dominique d'Humieres diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index f80a7c36265..d483de125f7 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -1552,7 +1552,7 @@ select_string (st_parameter_dt *dtp, const fnode *f, char *buf, size_t *size, int kind) { char *result; - *size = size_from_kind (dtp, f, kind) + f->u.real.d; + *size = size_from_kind (dtp, f, kind) + f->u.real.d + 1; if (*size > BUF_STACK_SZ) result = xmalloc (*size); else