summaryrefslogtreecommitdiffstats
path: root/src/H5Ofill.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-11-13 15:19:50 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-11-13 15:19:50 (GMT)
commite1792ebb22c1fee3eb349b83543e6e915bd1e6f7 (patch)
tree6e3f936d7809ff0191d17454ba0cb6047abda784 /src/H5Ofill.c
parent71f3513337e800f6500551448559cecc6853aca9 (diff)
downloadhdf5-e1792ebb22c1fee3eb349b83543e6e915bd1e6f7.zip
hdf5-e1792ebb22c1fee3eb349b83543e6e915bd1e6f7.tar.gz
hdf5-e1792ebb22c1fee3eb349b83543e6e915bd1e6f7.tar.bz2
[svn-r7842] Purpose:
Bug fix Description: Variable length strings and sequences with NULL pointers were not handled by library, causing problems access the data. This also affected fill values for variable-length datatypes. Solution: Address the issues in the library by detecting NULL sequences/strings and avoid trying to convert them. Patched up dumper to display NULL sequences/strings. Platforms tested: FreeBSD 4.9 (sleipnir) h5committest
Diffstat (limited to 'src/H5Ofill.c')
-rw-r--r--src/H5Ofill.c70
1 files changed, 36 insertions, 34 deletions
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index b2595a0..ec34202 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -877,42 +877,44 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type, hid_t dxpl_id)
/*
* Can we convert between source and destination data types?
*/
- if (NULL==(tpath=H5T_path_find(fill->type, dset_type, NULL, NULL, dxpl_id))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert between src and dst data types");
- }
- if ((src_id = H5I_register(H5I_DATATYPE,
- H5T_copy(fill->type, H5T_COPY_TRANSIENT)))<0 ||
- (dst_id = H5I_register(H5I_DATATYPE,
- H5T_copy(dset_type, H5T_COPY_TRANSIENT)))<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type");
-
- /*
- * Data type conversions are always done in place, so we need a buffer
- * that is large enough for both source and destination.
- */
- if (H5T_get_size(fill->type)>=H5T_get_size(dset_type)) {
- buf = fill->buf;
- } else {
- if (NULL==(buf=H5MM_malloc(H5T_get_size(dset_type))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
- HDmemcpy(buf, fill->buf, H5T_get_size(fill->type));
- }
- if (H5T_path_bkg(tpath) && NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ if (NULL==(tpath=H5T_path_find(fill->type, dset_type, NULL, NULL, dxpl_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types")
+
+ /* Don't bother doing anything if there will be no actual conversion */
+ if (!H5T_path_noop(tpath)) {
+ if ((src_id = H5I_register(H5I_DATATYPE,
+ H5T_copy(fill->type, H5T_COPY_TRANSIENT)))<0 ||
+ (dst_id = H5I_register(H5I_DATATYPE,
+ H5T_copy(dset_type, H5T_COPY_TRANSIENT)))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type");
+
+ /*
+ * Data type conversions are always done in place, so we need a buffer
+ * that is large enough for both source and destination.
+ */
+ if (H5T_get_size(fill->type)>=H5T_get_size(dset_type)) {
+ buf = fill->buf;
+ } else {
+ if (NULL==(buf=H5MM_malloc(H5T_get_size(dset_type))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ HDmemcpy(buf, fill->buf, H5T_get_size(fill->type));
+ }
+ if (H5T_path_bkg(tpath) && NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
- /* Do the conversion */
- if (H5T_convert(tpath, src_id, dst_id, (hsize_t)1, 0, 0, buf, bkg, dxpl_id)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed");
+ /* Do the conversion */
+ if (H5T_convert(tpath, src_id, dst_id, (hsize_t)1, 0, 0, buf, bkg, dxpl_id)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed");
- /* Update the fill message */
- if (buf!=fill->buf) {
- H5MM_xfree(fill->buf);
- fill->buf = buf;
- }
- H5T_close(fill->type);
- fill->type = NULL;
- H5_ASSIGN_OVERFLOW(fill->size,H5T_get_size(dset_type),size_t,ssize_t);
+ /* Update the fill message */
+ if (buf!=fill->buf) {
+ H5MM_xfree(fill->buf);
+ fill->buf = buf;
+ }
+ H5T_close(fill->type);
+ fill->type = NULL;
+ H5_ASSIGN_OVERFLOW(fill->size,H5T_get_size(dset_type),size_t,ssize_t);
+ } /* end if */
done:
if (src_id>=0)