From: Qing Zhao Date: Fri, 1 Dec 2017 18:20:45 +0000 (+0000) Subject: Fix an undefined behavior in fortran/decl.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8a302cb2b3cfc170254cf1d9fdc4dc2a681c15d1;p=gcc.git Fix an undefined behavior in fortran/decl.c From-SVN: r255332 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b7f8a5856e4..e5865dc892d 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 67e1c5bf314..d46083c0a93 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;