From 886c6f8cf24281cc6c6b6920cf7969cf2b6d3401 Mon Sep 17 00:00:00 2001 From: tradke Date: Tue, 24 Aug 2004 08:39:08 +0000 Subject: Fix from Yosef Zlochower: allocate attribute buffer with one more byte for the trailing NUL character. This closes PR CactusPUGHIO/1837: "Allocated memory too short to hold flexio attribute". git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@328 ebee0441-1374-4afa-a3b5-247f3ba15b9a --- src/util/ieee_merge.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/util/ieee_merge.c b/src/util/ieee_merge.c index a83ed9b..69ae252 100644 --- a/src/util/ieee_merge.c +++ b/src/util/ieee_merge.c @@ -13,6 +13,8 @@ #include #include +#include + /* CCTK includes */ #include "cctk.h" @@ -175,7 +177,8 @@ int main (int argc, char **argv) #endif } - attrData = malloc (IOnBytes (attrType, 1, &attrLen)); + /* for string attributes: allocate one more bytes for trailing NUL */ + attrData = malloc (IOnBytes (attrType, 1, &attrLen) + 1); if (IOreadAttribute (infile, j, attrData) < 0) { printf ("Cannot read value of attribute %d, skipping ...\n", j); -- cgit v1.2.3