diff options
Diffstat (limited to 'hl/test/test_image.c')
-rw-r--r-- | hl/test/test_image.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 38f1830..36dc734 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -13,8 +13,10 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include <limits.h> #include <stdlib.h> #include <string.h> + #include "h5hltest.h" #include "H5srcdir.h" #include "H5LTpublic.h" @@ -622,10 +624,12 @@ static int test_generate(void) if(n_elements > INT_MAX / (int)sizeof(float)) goto out; - data = (float *)HDmalloc((size_t)n_elements * sizeof( float )); - HDassert(data); - image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof( unsigned char )); - HDassert(image_data); + data = (float *)HDmalloc((size_t)n_elements * sizeof(float)); + if(NULL == data) + goto out; + image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); + if(NULL == image_data) + goto out; for ( i = 0; i < n_elements; i++ ) { @@ -794,9 +798,6 @@ static int read_data( const char* fname, /*IN*/ fscanf(f, "%s", str); fscanf(f, "%d", &w); - *width = (hsize_t)w; - *height = (hsize_t)h; - /* Check product for overflow */ if(w < 1 || h < 1 || color_planes < 1) goto out; @@ -813,13 +814,16 @@ static int read_data( const char* fname, /*IN*/ goto out; /* Release the buffer, if it was previously allocated */ - if(image_data) { + if(image_data) HDfree(image_data); - image_data = NULL; - } /* end if */ /* Allocate the image data buffer */ image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); + if(NULL == image_data) + goto out; + + *width = (hsize_t)w; + *height = (hsize_t)h; /* Read data elements */ for(i = 0; i < n_elements; i++) { |