backport: re PR libfortran/83168 (FAIL: gfortran.dg/fmt_f0_2.f90 with a sanitized libgfortran)

2017-12-03  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        Backport from trunk
        PR libgfortran/83168
        * io/write.c (select_string): Bump size by one to avoid
        overrun.

From-SVN: r255373
This commit is contained in:
Jerry DeLisle 2017-12-04 03:51:28 +00:00
parent 487568a811
commit fdef6a73f1
2 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2017-12-03 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Backport from trunk
PR libgfortran/83168
* io/write.c (select_string): Bump size by one to avoid
overrun.
2017-12-03 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2017-12-03 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Dominique d'Humieres <dominiq@lps.ens.fr> Dominique d'Humieres <dominiq@lps.ens.fr>

View File

@ -1552,7 +1552,7 @@ select_string (st_parameter_dt *dtp, const fnode *f, char *buf, size_t *size,
int kind) int kind)
{ {
char *result; 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) if (*size > BUF_STACK_SZ)
result = xmalloc (*size); result = xmalloc (*size);
else else