diff options
Diffstat (limited to 'hl')
-rw-r--r-- | hl/src/H5LT.c | 22 | ||||
-rw-r--r-- | hl/test/test_ds.c | 1 |
2 files changed, 19 insertions, 4 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index e797d14..c38d383 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1668,7 +1668,7 @@ print_enum(hid_t type, char* str, int indt) int nmembs; /*number of members */ char tmp_str[256]; int nchars; /*number of output characters */ - hid_t super; /*enum base integer type */ + hid_t super = -1; /*enum base integer type */ hid_t native = -1; /*native integer data type */ size_t super_size; /*enum base type size */ size_t dst_size; /*destination value type size */ @@ -1742,21 +1742,35 @@ print_enum(hid_t type, char* str, int indt) } /* Release resources */ - for (i = 0; i < nmembs; i++) + for(i = 0; i < nmembs; i++) free(name[i]); free(name); free(value); H5Tclose(super); - if (0 == nmembs) { + if(0 == nmembs) { sprintf(tmp_str, "\n%*s <empty>", indt + 4, ""); strcat(str, tmp_str); - } + } /* end if */ return ret; out: + /* Release resources */ + if(name) { + for(i = 0; i < nmembs; i++) + if(name[i]) + free(name[i]); + free(name); + } /* end if */ + + if(value) + free(value); + + if(super >= 0) + H5Tclose(super); + return FAIL; } diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 7e0f20e..32622ed 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -4889,6 +4889,7 @@ static int read_data( const char* fname, if ( *buf == NULL ) { printf( "memory allocation failed\n" ); + fclose(f); return -1; } |