From 512b4bfb4f52cef51501d91c6135be1b2e7e72c6 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/IOHDF5Util/trunk@127 7842ec3a-9562-4be5-9c5b-06ba18f2b668 --- src/RecoverVar.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/RecoverVar.c b/src/RecoverVar.c index 593dda4..90072a2 100644 --- a/src/RecoverVar.c +++ b/src/RecoverVar.c @@ -384,7 +384,7 @@ static int GetCommonAttributes (const cGH *GH, hid_t datatype, dataspace; hsize_t rank_stored, *dims_stored; int grouptype_stored, numtimelevels_stored; - char *groupname, *msg; + char *groupname, *msg, *oldmsg; char groupname_stored[128]; @@ -513,16 +513,24 @@ static int GetCommonAttributes (const cGH *GH, fullname, (int) dims_stored[0]); for (i = 1; i < group_static_data.dim; i++) { + oldmsg = msg; Util_asprintf (&msg, "%s, %d", msg, (int) 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