diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2004-08-24 08:39:08 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2004-08-24 08:39:08 +0000 |
commit | 886c6f8cf24281cc6c6b6920cf7969cf2b6d3401 (patch) | |
tree | beb0e0bba551006996b95905b0f9c98b368e2f8f | |
parent | eb3621c118d57c485c23d63bfdb005d05bb73e11 (diff) |
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
-rw-r--r-- | src/util/ieee_merge.c | 5 |
1 files changed, 4 insertions, 1 deletions
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 <stdio.h> #include <stdlib.h> +#include <string.h> + /* 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); |