summaryrefslogtreecommitdiffstats
path: root/src/H5S.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-07-23 17:54:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-07-23 17:54:32 (GMT)
commitccdd97ed9723ff6286a28ce5c79fcb2b493f8c6f (patch)
tree719b376b13212b69adcfae89001c3590720f36a6 /src/H5S.c
parent009da0a6ebb6251fae94a0d76bd1b07a9958b1d2 (diff)
downloadhdf5-ccdd97ed9723ff6286a28ce5c79fcb2b493f8c6f.zip
hdf5-ccdd97ed9723ff6286a28ce5c79fcb2b493f8c6f.tar.gz
hdf5-ccdd97ed9723ff6286a28ce5c79fcb2b493f8c6f.tar.bz2
[svn-r5826] Purpose:
Bug Fix Description: Dynamically allocated H5S_t structure was not being freed under certain error conditions. Solution: Free it. Platforms tested: FreeBSD 4.6 (sleipnir)
Diffstat (limited to 'src/H5S.c')
-rw-r--r--src/H5S.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/H5S.c b/src/H5S.c
index 1b88e5a..0aa9b18 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -1148,26 +1148,23 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds)
H5S_t *
H5S_read(H5G_entry_t *ent)
{
- H5S_t *ds = NULL;
+ H5S_t *ds = NULL; /* Dataspace to return */
+ H5S_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(H5S_read, NULL);
/* check args */
assert(ent);
- if (NULL==(ds = H5FL_ALLOC(H5S_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(ds = H5FL_ALLOC(H5S_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->extent.u.simple)) == NULL) {
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL,
- "unable to load dataspace info from dataset header");
- }
+ if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->extent.u.simple)) == NULL)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to load dataspace info from dataset header");
if(ds->extent.u.simple.rank != 0) {
ds->extent.type = H5S_SIMPLE;
- } else {
+ } else {
ds->extent.type = H5S_SCALAR;
}
@@ -1175,11 +1172,19 @@ H5S_read(H5G_entry_t *ent)
ds->select.type=H5S_SEL_ALL;
/* Allocate space for the offset and set it to zeros */
- if (NULL==(ds->select.offset = H5FL_ARR_ALLOC(hssize_t,ds->extent.u.simple.rank,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- }
+ if (NULL==(ds->select.offset = H5FL_ARR_ALLOC(hssize_t,ds->extent.u.simple.rank,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+
+ /* Set the value for successful return */
+ ret_value=ds;
+
+done:
+ if(ret_value==NULL) {
+ if(ds!=NULL)
+ H5FL_FREE(H5S_t,ds);
+ } /* end if */
- FUNC_LEAVE(ds);
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------