diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-03-28 18:21:37 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-03-28 18:21:37 (GMT) |
commit | dd081a1526e6e8ebec01ad26682ff236e43b2005 (patch) | |
tree | 34864fb5370179021df97656b4f29bf84cc39631 | |
parent | 5ba3f038fae45063cd91bd1a66ad96421e8cb4a0 (diff) | |
download | hdf5-dd081a1526e6e8ebec01ad26682ff236e43b2005.zip hdf5-dd081a1526e6e8ebec01ad26682ff236e43b2005.tar.gz hdf5-dd081a1526e6e8ebec01ad26682ff236e43b2005.tar.bz2 |
[svn-r13559]
bug fix
a malloc call with an incorrect length caused several memory problems
that ultimately corrupted a name passed in a list of arguments in the
h52gif tool
allocated memory was not freed
created a folder for the gif test binary files and made the shell script
use that file
tested linux, AIX, solaris
-rw-r--r-- | MANIFEST | 4 | ||||
-rw-r--r-- | hl/tools/gif2h5/h52gifgentst.c | 2 | ||||
-rw-r--r-- | hl/tools/gif2h5/h52giftest.sh | 7 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdf2gif.c | 19 | ||||
-rw-r--r-- | hl/tools/testfiles/h52giftst.h5 (renamed from tools/testfiles/h52giftst.h5) | bin | 82816 -> 82816 bytes |
5 files changed, 17 insertions, 15 deletions
@@ -1993,9 +1993,7 @@ ./hl/tools/gif2h5/writehdf.c ./hl/tools/gif2h5/h52gifgentst.c ./hl/tools/gif2h5/h52giftest.sh -# -./tools/testfiles/h52giftst.h5 - +./hl/tools/testfiles/h52giftst.h5 # windows diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c index 717f9aa..d25b8ac 100644 --- a/hl/tools/gif2h5/h52gifgentst.c +++ b/hl/tools/gif2h5/h52gifgentst.c @@ -36,7 +36,7 @@ #define WIDTH (hsize_t)400 #define HEIGHT (hsize_t)200 #define PAL_ENTRIES 256 -#define IMAGE1_NAME "1234567" +#define IMAGE1_NAME "12345678" #define PAL_NAME "palette" /*------------------------------------------------------------------------- diff --git a/hl/tools/gif2h5/h52giftest.sh b/hl/tools/gif2h5/h52giftest.sh index b07ec90..fa439aa 100644 --- a/hl/tools/gif2h5/h52giftest.sh +++ b/hl/tools/gif2h5/h52giftest.sh @@ -15,6 +15,8 @@ # # HDF Utilities Test script +TESTFILE="$srcdir/../testfiles/h52giftst.h5" + # initialize errors variable errors=0 @@ -28,7 +30,6 @@ TOOLTEST() err=0 $RUNSERIAL ./h52gif $* - if [ $err -eq 1 ]; then errors="` expr $errors + 1 `"; echo "*FAILED*" @@ -39,8 +40,8 @@ fi -TESTING "h52giftst.h5 image1.gif -i 1234567 -p palette" ; -TOOLTEST h52giftst.h5 image1.gif -i 1234567 -p palette +TESTING "h52giftst.h5 image1.gif -i 12345678 -p palette" ; +TOOLTEST $TESTFILE image1.gif -i 12345678 -p palette exit $errors diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index cb8813f..8f06bd2 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -149,7 +149,8 @@ int main(int argc , char **argv) if (bool_is_image) { /* this is an image */ /* allocate space to store the image name */ - image_name_arr[number_of_images] = (CHAR*) malloc(strlen(argv[arg_index] + 1)); + size_t len = strlen(argv[arg_index]); + image_name_arr[number_of_images] = (CHAR*) malloc( len + 1); strcpy(image_name_arr[number_of_images] , argv[arg_index]); /* make the palette array for this NULL */ @@ -163,7 +164,8 @@ int main(int argc , char **argv) /* this is a palette */ /* allocate space to store the pal name */ /* the palette was probably allocated for a previous image */ - pal_name_arr[number_of_images-1] = (CHAR*) malloc(strlen(argv[arg_index] + 1)); + size_t len = strlen(argv[arg_index]); + pal_name_arr[number_of_images-1] = (CHAR*) malloc( len + 1); strcpy(pal_name_arr[number_of_images - 1], argv[arg_index]); bool_is_palette = 0; continue; @@ -172,12 +174,10 @@ int main(int argc , char **argv) /* oops. This was not meant to happen */ usage(); -#if 0 while (number_of_images--) { cleanup(image_name_arr[number_of_images]); cleanup(pal_name_arr[number_of_images]); } -#endif /* 0 */ return -1; } @@ -216,8 +216,8 @@ int main(int argc , char **argv) return -1; } - assert(dim_sizes[0]==(hsize_t)((int)dim_sizes[0])); - assert(dim_sizes[1]==(hsize_t)((int)dim_sizes[1])); + assert(dim_sizes[0]==(hsize_t)((int)dim_sizes[0])); + assert(dim_sizes[1]==(hsize_t)((int)dim_sizes[1])); RWidth = (int)dim_sizes[1]; RHeight = (int)dim_sizes[0]; #ifdef UNUSED @@ -392,14 +392,17 @@ int main(int argc , char **argv) fclose(fpGif); -#if 0 + if (HDFName != NULL) + free(HDFName); + if (GIFName != NULL) + free(GIFName); + while(number_of_images--) { if (image_name_arr[number_of_images]) free(image_name_arr[number_of_images]); if (pal_name_arr[number_of_images]) free(pal_name_arr[number_of_images]); } -#endif /* 0 */ return 0; } diff --git a/tools/testfiles/h52giftst.h5 b/hl/tools/testfiles/h52giftst.h5 Binary files differindex 29a75b5..6dc499b 100644 --- a/tools/testfiles/h52giftst.h5 +++ b/hl/tools/testfiles/h52giftst.h5 |