diff options
author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-16 17:43:03 +0000 |
---|---|---|
committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-16 17:43:03 +0000 |
commit | d151c82cf60c5d1350012dd0e79546c5e5c3e2ca (patch) | |
tree | a18b46c3ac70b0e29558cbe228eaa2af23e758b9 /libgfortran/io/write.c | |
parent | 39ec41d495144d434782654e483b1adcb672f55e (diff) | |
download | ppe42-gcc-d151c82cf60c5d1350012dd0e79546c5e5c3e2ca.tar.gz ppe42-gcc-d151c82cf60c5d1350012dd0e79546c5e5c3e2ca.zip |
Replace sprintf with snprintf
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172590 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io/write.c')
-rw-r--r-- | libgfortran/io/write.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 4733d51e882..5338162bc6c 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Andy Vaught Namelist output contributed by Paul Thomas @@ -1689,6 +1689,7 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset, char cup; char * obj_name; char * ext_name; + size_t ext_name_len; char rep_buff[NML_DIGITS]; namelist_info * cmp; namelist_info * retval = obj->next; @@ -1797,7 +1798,7 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset, { if (rep_ctr > 1) { - sprintf(rep_buff, " %d*", rep_ctr); + snprintf(rep_buff, NML_DIGITS, " %d*", rep_ctr); write_character (dtp, rep_buff, 1, strlen (rep_buff)); dtp->u.p.no_leading_blank = 1; } @@ -1851,11 +1852,9 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset, base_name_len = base_name ? strlen (base_name) : 0; base_var_name_len = base ? strlen (base->var_name) : 0; - ext_name = (char*)get_mem ( base_name_len - + base_var_name_len - + strlen (obj->var_name) - + obj->var_rank * NML_DIGITS - + 1); + ext_name_len = base_name_len + base_var_name_len + + strlen (obj->var_name) + obj->var_rank * NML_DIGITS + 1; + ext_name = (char*)get_mem (ext_name_len); memcpy (ext_name, base_name, base_name_len); clen = strlen (obj->var_name + base_var_name_len); @@ -1872,7 +1871,8 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset, ext_name[tot_len] = '('; tot_len++; } - sprintf (ext_name + tot_len, "%d", (int) obj->ls[dim_i].idx); + snprintf (ext_name + tot_len, ext_name_len - tot_len, "%d", + (int) obj->ls[dim_i].idx); tot_len += strlen (ext_name + tot_len); ext_name[tot_len] = ((int) dim_i == obj->var_rank - 1) ? ')' : ','; tot_len++; |