summaryrefslogtreecommitdiffstats
path: root/src/H5HFsection.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-10-02 20:00:21 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-10-02 20:00:21 (GMT)
commit22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e (patch)
tree4509bae15cd445b09e38584d5bee2b2fc27ae67a /src/H5HFsection.c
parentfa94f16ad894ccbd3ab5b3a7a0f9bf74c6ea4d9e (diff)
downloadhdf5-22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e.zip
hdf5-22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e.tar.gz
hdf5-22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e.tar.bz2
[svn-r14175] Description:
Minor fixes to avoid memory leaks when 'realloc' fails. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5HFsection.c')
-rw-r--r--src/H5HFsection.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/H5HFsection.c b/src/H5HFsection.c
index e031ed2..62af976 100644
--- a/src/H5HFsection.c
+++ b/src/H5HFsection.c
@@ -3909,9 +3909,12 @@ HDfprintf(stderr, "%s: nrows_moved2 = %u\n", FUNC, nrows_moved2);
/* Check if we need to move additional rows */
if(nrows_moved2 > 0) {
+ H5HF_free_section_t **new_dir_rows; /* Pointer to new array of direct row pointers */
+
/* Extend the first section's row array */
- if(NULL == (sect1->u.indirect.dir_rows = H5MM_realloc(sect1->u.indirect.dir_rows, sizeof(H5HF_free_section_t *) * new_dir_nrows1)))
+ if(NULL == (new_dir_rows = H5MM_realloc(sect1->u.indirect.dir_rows, sizeof(H5HF_free_section_t *) * new_dir_nrows1)))
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array")
+ sect1->u.indirect.dir_rows = new_dir_rows;
/* Transfer the second section's rows to first section */
HDmemcpy(&sect1->u.indirect.dir_rows[sect1->u.indirect.dir_nrows],
@@ -3952,9 +3955,12 @@ HDfprintf(stderr, "%s: nrows_moved2 = %u\n", FUNC, nrows_moved2);
sect2->u.indirect.indir_ents = NULL;
} /* end if */
else {
+ H5HF_free_section_t **new_indir_ents; /* Pointer to new array of indirect entries */
+
/* Extend the first section's entry array */
- if(NULL == (sect1->u.indirect.indir_ents = H5MM_realloc(sect1->u.indirect.indir_ents, sizeof(H5HF_free_section_t *) * new_indir_nents1)))
+ if(NULL == (new_indir_ents = H5MM_realloc(sect1->u.indirect.indir_ents, sizeof(H5HF_free_section_t *) * new_indir_nents1)))
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array")
+ sect1->u.indirect.indir_ents = new_indir_ents;
/* Transfer the second section's entries to first section */
HDmemcpy(&sect1->u.indirect.indir_ents[sect1->u.indirect.indir_nents],