summaryrefslogtreecommitdiffstats
path: root/src/H5Ztrans.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2004-09-22 01:18:47 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2004-09-22 01:18:47 (GMT)
commit9d9621ef0c2670b9813b36d74a665b04fe105cf0 (patch)
treed0c6f62851bb830b1de3eef9b91901acc67ddf50 /src/H5Ztrans.c
parenta4e1edbdba674822949dc8695333c0d23018197c (diff)
downloadhdf5-9d9621ef0c2670b9813b36d74a665b04fe105cf0.zip
hdf5-9d9621ef0c2670b9813b36d74a665b04fe105cf0.tar.gz
hdf5-9d9621ef0c2670b9813b36d74a665b04fe105cf0.tar.bz2
[svn-r9297] Purpose:
Bug fix. Description: Code would attempt to Calloc with zero count when a simple expression that has no x term. That resulted in NULL for some platform (like AIX). That appeared as a failure treated as out of space. Solution: Checked if count is larger than 0 before making the calloc request. Platforms tested: Tested in copper (pp) where the failure appeared. Also in eirene as double check. No h5committest as the change is trivial.
Diffstat (limited to 'src/H5Ztrans.c')
-rw-r--r--src/H5Ztrans.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 38e966f..f17319d 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -1685,9 +1685,13 @@ H5Z_xform_create(const char *expr)
if(isalpha(expr[i]))
count++;
}
- if((data_xform_prop->dat_val_pointers->ptr_dat_val = (void*) HDcalloc(count, sizeof(void*))) == NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array")
-
+ /* When there are no "x"'s in the equation (ie, simple transform case),
+ * we don't need to allocate any space since no array will have to be
+ * stored */
+ if(count > 0)
+ if((data_xform_prop->dat_val_pointers->ptr_dat_val = (void*) HDcalloc(count, sizeof(void*))) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array")
+
/* Initialize the num_ptrs field, which will be used to keep track of the number of copies
* of the data we have for polynomial transforms */
data_xform_prop->dat_val_pointers->num_ptrs = 0;
@@ -1807,8 +1811,9 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop)
if(isalpha(new_data_xform_prop->xform_exp[i]))
count++;
}
- if((new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void*) HDcalloc(count, sizeof(void*))) == NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array")
+ if(count > 0)
+ if((new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void*) HDcalloc(count, sizeof(void*))) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array")
/* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right amount */
new_data_xform_prop->dat_val_pointers->num_ptrs = 0;