summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Arber <larber@ncsa.uiuc.edu>2004-11-12 02:40:14 (GMT)
committerLeon Arber <larber@ncsa.uiuc.edu>2004-11-12 02:40:14 (GMT)
commit5d7425c68641e5ac0a2f75d8fbfe512582582395 (patch)
tree84fd294d954695d400256559ab278e8d6014e690
parent73a495e7ac5af18c3ad695da8eb2ead79c1a218c (diff)
downloadhdf5-5d7425c68641e5ac0a2f75d8fbfe512582582395.zip
hdf5-5d7425c68641e5ac0a2f75d8fbfe512582582395.tar.gz
hdf5-5d7425c68641e5ac0a2f75d8fbfe512582582395.tar.bz2
[svn-r9524] Purpose:
Bug Fix Description: Fixed off by one error in H5Pget_data_transform Solution: H5Pget_data_transform, when queried for the size of the property, should return strlen() + 1 so that the user can allocate memory for the terminating \0 in the string. Also fixed a typo in a comment in H5Ztrans.c Platforms tested: eirene, too minor to require further testing. Misc. update:
-rw-r--r--src/H5Pdxpl.c5
-rw-r--r--src/H5Ztrans.c17
2 files changed, 17 insertions, 5 deletions
diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c
index 49fece6..37db704 100644
--- a/src/H5Pdxpl.c
+++ b/src/H5Pdxpl.c
@@ -115,7 +115,6 @@ ssize_t H5Pget_data_transform(hid_t plist_id, char* expression /*out*/, size_t s
size_t len;
char* pexp;
-
FUNC_ENTER_API(H5Pget_data_transform, FAIL);
/* Get the plist structure */
@@ -134,6 +133,8 @@ ssize_t H5Pget_data_transform(hid_t plist_id, char* expression /*out*/, size_t s
if(!pexp)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Failed to retrieve transform expression");
+
+
len = HDstrlen(pexp);
if(expression)
{
@@ -142,7 +143,7 @@ ssize_t H5Pget_data_transform(hid_t plist_id, char* expression /*out*/, size_t s
expression[size-1]='\0';
}
- ret_value = (ssize_t)len;
+ ret_value = (ssize_t)len + 1;
done:
if(ret_value<0) {
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index d14af45..c1feb7a 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -1391,6 +1391,11 @@ H5Z_xform_create(const char *expr)
if((data_xform_prop->parse_root = H5Z_xform_parse(expr, data_xform_prop->dat_val_pointers))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to generate parse tree from expression")
+ /* Sanity check
+ * count should be the same num_ptrs */
+ if(count != data_xform_prop->dat_val_pointers->num_ptrs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "error copying the parse tree, did not find correct number of \"variables\"")
+
/* Assign return value */
ret_value=data_xform_prop;
@@ -1513,10 +1518,16 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop)
/* 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;
-
+
+
/* Copy parse tree */
if((new_data_xform_prop->parse_root = (H5Z_node*)H5Z_xform_copy_tree((*data_xform_prop)->parse_root, (*data_xform_prop)->dat_val_pointers, new_data_xform_prop->dat_val_pointers)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "error copying the parse tree")
+
+ /* Sanity check
+ * count should be the same num_ptrs */
+ if(count != new_data_xform_prop->dat_val_pointers->num_ptrs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "error copying the parse tree, did not find correct number of \"variables\"")
/* Copy new information on top of old information */
*data_xform_prop=new_data_xform_prop;
@@ -1591,8 +1602,8 @@ H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop)
FUNC_ENTER_NOAPI_NOFUNC(H5Z_xform_extract_xform_str)
- /* There should be no way that these can be NULL since the function
- * that calls this one checks to make sure they aren't before
+ /* There should be no way that this can be NULL since the function
+ * that calls this one checks to make sure it isn't before
* pasing them */
assert(data_xform_prop);