diff options
Diffstat (limited to 'hl/src')
-rw-r--r-- | hl/src/H5LT.c | 27 | ||||
-rw-r--r-- | hl/src/H5PT.c | 11 | ||||
-rw-r--r-- | hl/src/H5TB.c | 63 | ||||
-rw-r--r-- | hl/src/Makefile.in | 10 |
4 files changed, 60 insertions, 51 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index e797d14..d118942 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,36 @@ 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) { + return ret; + +out: + + if(0 == nmembs) { sprintf(tmp_str, "\n%*s <empty>", indt + 4, ""); strcat(str, tmp_str); - } + } /* end if */ + + /* Release resources */ + if(name) { + for(i = 0; i < nmembs; i++) + if(name[i]) + free(name[i]); + free(name); + } /* end if */ - return ret; + if(value) + free(value); + + if(super >= 0) + H5Tclose(super); -out: return FAIL; } diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index 10d2637..3d16db5 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -214,6 +214,11 @@ out: * * Modifications: * + * John Mainzer -- 4/23/08 + * Added error check on malloc of table, initialized fields + * in table to keep lower level code from choking on bogus + * data in error cases. + * *------------------------------------------------------------------------- */ hid_t H5PTopen( hid_t loc_id, @@ -232,6 +237,12 @@ hid_t H5PTopen( hid_t loc_id, table = (htbl_t *)malloc(sizeof(htbl_t)); + if ( table == NULL ) { + goto out; + } + table->dset_id = H5I_BADID; + table->type_id = H5I_BADID; + /* Open the dataset */ if((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index a035319..b9cb73c 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -3213,16 +3213,12 @@ herr_t H5TBget_field_info( hid_t loc_id, size_t *field_offsets, size_t *type_size ) { - hid_t did; /* dataset ID */ - hid_t tid; /* file type ID */ - hid_t n_tid; /* native type ID */ - hid_t m_tid; /* member type ID */ - hid_t nm_tid; /* native member ID */ + hid_t did = -1; /* dataset ID */ + hid_t tid = -1; /* file type ID */ + hid_t n_tid = -1; /* native type ID */ + hid_t m_tid = -1; /* member type ID */ + hid_t nm_tid = -1; /* native member ID */ hssize_t nfields; - char *member_name; - size_t member_size; - size_t member_offset; - size_t size; hssize_t i; /* open the dataset. */ @@ -3233,62 +3229,47 @@ herr_t H5TBget_field_info( hid_t loc_id, if (( tid = H5Dget_type( did )) < 0) goto out; - if ((n_tid = H5Tget_native_type(tid,H5T_DIR_DEFAULT)) < 0) + if ((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0) goto out; /* get the type size */ - size = H5Tget_size( n_tid ); - - if ( type_size ) - { - *type_size = size; - } + if(type_size) + *type_size = H5Tget_size(n_tid); /* get the number of members */ if (( nfields = H5Tget_nmembers( tid )) < 0) goto out; /* iterate tru the members */ - for ( i = 0; i < nfields; i++) - { + for ( i = 0; i < nfields; i++) { /* get the member name */ - member_name = H5Tget_member_name( tid, (unsigned)i ); + if(field_names) { + char *member_name; - if (field_names ) - { - strcpy( field_names[i], member_name ); - } + member_name = H5Tget_member_name(tid, (unsigned)i); + strcpy(field_names[i], member_name); + free(member_name); + } /* end if */ /* get the member type */ - if (( m_tid = H5Tget_member_type( tid,(unsigned) i )) < 0) + if(( m_tid = H5Tget_member_type( tid,(unsigned) i )) < 0) goto out; - if ((nm_tid = H5Tget_native_type(m_tid,H5T_DIR_DEFAULT)) < 0) + if((nm_tid = H5Tget_native_type(m_tid,H5T_DIR_DEFAULT)) < 0) goto out; /* get the member size */ - member_size = H5Tget_size( nm_tid ); - - if(field_sizes ) - { - field_sizes[i] = member_size; - } + if(field_sizes) + field_sizes[i] = H5Tget_size(nm_tid); /* get the member offset */ - member_offset = H5Tget_member_offset( n_tid,(unsigned) i ); - - if(field_offsets ) - { - field_offsets[i] = member_offset; - } + if(field_offsets) + field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned) i); /* close the member types */ if (H5Tclose( m_tid ) < 0) goto out; if (H5Tclose( nm_tid ) < 0) goto out; - - free( member_name ); - } /* i */ /* close */ @@ -3308,6 +3289,8 @@ out: H5Dclose(did); H5Tclose(tid); H5Tclose(n_tid); + H5Tclose(m_tid); + H5Tclose(nm_tid); } H5E_END_TRY; return -1; diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index 0e3bd46..36ebcf9 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -341,12 +341,12 @@ CP = cp # Some machines need a command to run executables; this is that command # so that our tests will run. -# We use RUNTESTS instead of RUNSERIAL directly because it may be that +# We use RUNEXEC instead of RUNSERIAL directly because it may be that # some tests need to be run with a different command. Older versions # of the makefiles used the command # $(LIBTOOL) --mode=execute # in some directories, for instance. -RUNTESTS = $(RUNSERIAL) +RUNEXEC = $(RUNSERIAL) # Libraries to link to while building LIBHDF5 = $(top_builddir)/src/libhdf5.la @@ -380,7 +380,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 44 +LT_VERS_REVISION = 49 LT_VERS_AGE = 0 # This library is our main target. @@ -866,7 +866,7 @@ $(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_: fi; \ echo "============================" >> $${log}; \ srcdir="$(srcdir)" \ - $(TIME) $(RUNTESTS) ./$${tname} $(TEST_FLAGS) >> $${log} 2>&1 \ + $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) >> $${log} 2>&1 \ && touch $(@:.chkexe_=.chkexe) || \ (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ (cat $${log} && false) || exit 1; \ @@ -937,7 +937,7 @@ build-check-p: $(LIB) $(PROGS) $(TESTS) @for test in $(TEST_PROG_PARA) dummy; do \ if test $$test != dummy; then \ $(MAKE) $(AM_MAKEFLAGS) $$test.chkexe_ \ - RUNTESTS="$(RUNPARALLEL)" || exit 1; \ + RUNEXEC="$(RUNPARALLEL)" || exit 1; \ fi; \ done @for test in $(TEST_SCRIPT_PARA) dummy; do \ |