From 8a302cb2b3cfc170254cf1d9fdc4dc2a681c15d1 Mon Sep 17 00:00:00 2001 From: Qing Zhao Date: Fri, 1 Dec 2017 18:20:45 +0000 Subject: Fix an undefined behavior in fortran/decl.c From-SVN: r255332 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/decl.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b7f8a58..e5865dc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2017-12-01 Qing Zhao + + * decl.c (gfc_get_pdt_instance): Adjust the call to sprintf + to avoid the same buffer being both source and destination. + 2017-12-01 Thomas Koenig PR fortran/83224 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 67e1c5b..d46083c 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -3362,7 +3362,7 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym, } gfc_extract_int (kind_expr, &kind_value); - sprintf (name, "%s_%d", name, kind_value); + sprintf (name + strlen (name), "_%d", kind_value); if (!name_seen && actual_param) actual_param = actual_param->next; -- cgit v1.1