diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-04-30 20:04:44 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-04-30 20:04:44 (GMT) |
commit | 0fc9d137d3c00ec749152132db222d4a07bdc30f (patch) | |
tree | 0503d6055b6a1652dc57e2ff0085c783d8f40ba3 | |
parent | 78e4e6f008b8eba2930880058c5e475e2ee2691e (diff) | |
download | hdf5-0fc9d137d3c00ec749152132db222d4a07bdc30f.zip hdf5-0fc9d137d3c00ec749152132db222d4a07bdc30f.tar.gz hdf5-0fc9d137d3c00ec749152132db222d4a07bdc30f.tar.bz2 |
[svn-r10703] Purpose:
Bug fix
Description:
Correct bug where buffers that have only fractional elements (usually from
being compressed before being shuffled) would cause optimized algorithm to
dump core.
Solution:
Don't attempt to shuffle bytes unless we've got more than one element.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Too minor to require h5committest
-rw-r--r-- | src/H5Zshuffle.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index 301aafd..d97676e 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -78,7 +78,7 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id) #ifdef H5_WANT_H5_V1_6_COMPAT if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0) #else - if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL,NULL)<0) + if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,(size_t)0,NULL,NULL)<0) #endif HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") @@ -87,7 +87,7 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Modify the filter's parameters for this dataset */ - if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SHUFFLE, flags, H5Z_SHUFFLE_TOTAL_NPARMS, cd_values)<0) + if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SHUFFLE, flags, (size_t)H5Z_SHUFFLE_TOTAL_NPARMS, cd_values)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters") done: @@ -142,11 +142,11 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Get the number of bytes per element from the parameter block */ bytesoftype=cd_values[H5Z_SHUFFLE_PARM_SIZE]; - /* Don't do anything for 1-byte elements */ - if(bytesoftype>1) { - /* Compute the number of elements in buffer */ - numofelements=nbytes/bytesoftype; + /* Compute the number of elements in buffer */ + numofelements=nbytes/bytesoftype; + /* Don't do anything for 1-byte elements, or "fractional" elements */ + if(bytesoftype > 1 && numofelements > 1) { /* Compute the leftover bytes if there are any */ leftover = nbytes%bytesoftype; |