From 693131fe40f5c4c014abc590be01bacb9ccdedb7 Mon Sep 17 00:00:00 2001 From: MuQun Yang Date: Wed, 14 Mar 2001 14:14:13 -0500 Subject: [svn-r3632] Purpose: a bug fix on windows(possible on other platforms) Description: not allocating enough space for a string at dump_all for debug version a string tmp is defined at dump_all(....), The memory that is allocated to tmp is malloc(strlen(prefix)+strlen(name)+1); However, there is one testing case : strlen(prefix) is 0 and tmp is allocated in the following: strcat(tmp,"/"); strcat(tmp,name); .... free(tmp); the program fails when freeing tmp for debug (dll) version on windows 2000 Solution: For windows platform: allocate memory strlen(prefix)+strlen(name)+2 Platforms tested: [machines you have tested the changed version. This is absolute important. Test it out on at least two or three different platforms such as Big-endian-32bit (SUN/IRIX), little-endian-32(LINUX) and 64-bit (IRIX64/UNICOS/DEC-ALPHA) would be good.] --- tools/h5dump/h5dump.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 0c87b17..c24b2d4 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1274,8 +1274,11 @@ dump_all(hid_t group, const char *name, void * op_data) if (*(int *)op_data != H5G_UNKNOWN && statbuf.type != *(int *) op_data) goto done; - +#ifdef WIN32 + tmp = malloc(strlen(prefix)+strlen(name)+2); +#else tmp = malloc(strlen(prefix) + strlen(name) + 1); +#endif strcpy(tmp, prefix); switch (statbuf.type) { -- cgit v0.12