From 8bcbcdf8830366b8f789d4e5c3a4dd8514aead14 Mon Sep 17 00:00:00 2001 From: tradke Date: Tue, 26 Jul 2005 15:03:04 +0000 Subject: Fixed small memory when using Util_snprintf(). git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@337 ebee0441-1374-4afa-a3b5-247f3ba15b9a --- src/RestoreFile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/RestoreFile.c') diff --git a/src/RestoreFile.c b/src/RestoreFile.c index 579576a..1867caa 100644 --- a/src/RestoreFile.c +++ b/src/RestoreFile.c @@ -404,7 +404,7 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex, cGroupDynamicData group_dynamic_data; CCTK_INT4 grouptype_stored, numtimelevels_stored, timelevel_stored, iteration_stored; - char *groupname, *msg; + char *groupname, *msg, *oldmsg; const int *dims; int dims_stored[MAXDIM]; char fullname[512], groupname_stored[512]; @@ -595,16 +595,24 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex, fullname, dims_stored[0]); for (i = 1; i < group_static_data.dim; i++) { + oldmsg = msg; Util_asprintf (&msg, "%s, %d", msg, dims_stored[i]); + free (oldmsg); } dims = unchunked ? group_dynamic_data.gsh : group_dynamic_data.lsh; + oldmsg = msg; Util_asprintf (&msg, "%s), expected (%d", msg, dims[group_static_data.dim - 1]); + free (oldmsg); for (i = 1; i < group_static_data.dim; i++) { + oldmsg = msg; Util_asprintf (&msg, "%s, %d", msg, dims[group_static_data.dim-i-1]); + free (oldmsg); } + oldmsg = msg; Util_asprintf (&msg, "%s)", msg); + free (oldmsg); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, msg); free (msg); } -- cgit v1.2.3