Fix an undefined behavior in fortran/decl.c

From-SVN: r255332
This commit is contained in:
Qing Zhao 2017-12-01 18:20:45 +00:00 committed by Qing Zhao
parent 1cde289f1c
commit 8a302cb2b3
2 changed files with 6 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2017-12-01 Qing Zhao <qing.zhao@oracle.com>
* 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 <tkoenig@gcc.gnu.org>
PR fortran/83224

View file

@ -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;