diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-02-08 04:01:08 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-02-08 04:01:08 (GMT) |
commit | 20b58606caaff62d70a7bdfc03dcead16e1e30d4 (patch) | |
tree | ee342f772ca87f28b4041b6eb48eb6c8258b66e2 /fortran | |
parent | 832a3db9a3a2c0d033d3c299948cbe51a816abe5 (diff) | |
download | hdf5-20b58606caaff62d70a7bdfc03dcead16e1e30d4.zip hdf5-20b58606caaff62d70a7bdfc03dcead16e1e30d4.tar.gz hdf5-20b58606caaff62d70a7bdfc03dcead16e1e30d4.tar.bz2 |
[svn-r20062] Description:
Bring r20061 from trunk to 1.8 branch:
Bring changes from Coverity branch to trunk:
r19930:
Fix memory leaks involving VL attributes in h5repack and h5diff. The buffers in
copy_attr and diff_attr were not checked for the presence of a vlen before being
freed, and vlen storage was never reclaimed. Added checks and calls to
H5D_vlen_reclaim().
r19933:
Purpose: Fix memory leak in H5L_move_cb()
Description: H5L_move_cb copied the source link using H5O_msg_copy() but freed
it manually using H5MM_xfree(). Since H5O_link_copy allocates the link using
H5FL_MALLOC, this causes the link to be allocated from the free list but is
never put back on the free list when it is freed. This prevents the link free
list from shutting down properly. Modified H5L_move_cb() and H5L_move_dest_cb()
to free the link properly using H5O_msg_free().
r19973:
Fix resource leaks by freeing string created by HD5f2string
r19974:
Issue #345: Inialize buf variable to null
Tested on:
Mac OS X/32 10.6.6 (amazon) w/debug & production
(h5committested on Coverity branch)
Diffstat (limited to 'fortran')
-rw-r--r-- | fortran/src/H5Ff.c | 33 | ||||
-rw-r--r-- | fortran/src/H5Lf.c | 13 |
2 files changed, 24 insertions, 22 deletions
diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c index 1570bb3..3cfc9e3 100644 --- a/fortran/src/H5Ff.c +++ b/fortran/src/H5Ff.c @@ -47,37 +47,36 @@ nh5fcreate_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f* crt_prp, h * Define access flags */ c_access_flags = (unsigned) *access_flags; + /* * Define creation property */ c_crt_prp = *crt_prp; -/* - if ( H5P_DEFAULT_F == c_crt_prp ) c_crt_prp = H5P_DEFAULT; -*/ + /* * Define access property */ c_acc_prp = *acc_prp; -/* - if ( H5P_DEFAULT_F == c_acc_prp ) c_acc_prp = H5P_DEFAULT; -*/ /* * Convert FORTRAN name to C name */ c_namelen = *namelen; c_name = (char *)HD5f2cstring(name, (size_t)c_namelen); - if (c_name == NULL) return ret_value; + if(c_name == NULL) + return ret_value; /* * Call H5Fcreate function. */ c_file_id = H5Fcreate(c_name, c_access_flags, c_crt_prp, c_acc_prp); - if (c_file_id < 0) return ret_value; - *file_id = c_file_id; + if (c_file_id >= 0) { + ret_value = 0; + *file_id = c_file_id; + } + HDfree(c_name); - ret_value = 0; return ret_value; } @@ -238,31 +237,31 @@ nh5fopen_c (_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *acc_prp, hi * Define access flags */ c_access_flags = (unsigned) *access_flags; + /* * Define access property */ c_acc_prp = *acc_prp; -/* - if ( H5P_DEFAULT_F == c_acc_prp ) c_acc_prp = H5P_DEFAULT; -*/ /* * Convert FORTRAN name to C name */ c_namelen = *namelen; c_name = (char *)HD5f2cstring(name, (size_t)c_namelen); - if (c_name == NULL) return ret_value; + if(c_name == NULL) + return ret_value; /* * Call H5Fopen function. */ c_file_id = H5Fopen(c_name, c_access_flags, c_acc_prp); - if (c_file_id < 0) return ret_value; - *file_id = (hid_t_f)c_file_id; + if(c_file_id >= 0) { + ret_value = 0; + *file_id = (hid_t_f)c_file_id; + } /* end if */ HDfree(c_name); - ret_value = 0; return ret_value; } diff --git a/fortran/src/H5Lf.c b/fortran/src/H5Lf.c index 59f4535..c971d5e 100644 --- a/fortran/src/H5Lf.c +++ b/fortran/src/H5Lf.c @@ -394,7 +394,7 @@ done: * Modifications: N/A *---------------------------------------------------------------------------*/ int_f -nh5lget_info_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, +nh5lget_info_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, int_f *cset, int_f *corder, int_f *corder_valid, int_f *link_type, haddr_t_f *address, size_t_f *val_size, hid_t_f *lapl_id) @@ -406,16 +406,16 @@ nh5lget_info_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, /* * Convert FORTRAN name to C name */ - if((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL) - HGOTO_DONE(FAIL); + if(NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen))) + HGOTO_DONE(FAIL); + /* * Call H5Linfo function. */ if(H5Lget_info((hid_t)*link_loc_id, c_link_name, &link_buff, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); + HGOTO_DONE(FAIL); /* Unpack the structure */ - *cset = (int_f)link_buff.cset; *corder = (int_f)link_buff.corder; *corder_valid = 0; @@ -425,6 +425,9 @@ nh5lget_info_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, *val_size = (size_t_f)link_buff.u.val_size; done: + if(c_link_name) + HDfree(c_link_name); + return ret_value; } |