summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-03-10 04:50:28 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-03-10 04:50:28 (GMT)
commit1bca28acc3294e465d22e4dee8ecfc92fbc55ebe (patch)
tree30240cc3dce025a1637e3962d0faad262fc089c6 /src
parent56b7fd71a3ccf6b5e200cd5fc0669302c309b73e (diff)
downloadhdf5-1bca28acc3294e465d22e4dee8ecfc92fbc55ebe.zip
hdf5-1bca28acc3294e465d22e4dee8ecfc92fbc55ebe.tar.gz
hdf5-1bca28acc3294e465d22e4dee8ecfc92fbc55ebe.tar.bz2
[svn-r13485] Description:
Fix reference to uninitialized memory, which could trigger a memory corruption, once in a purple moon. Tested on: FreeBSD/32 6.2 (duty) w/valgrind
Diffstat (limited to 'src')
-rw-r--r--src/H5Z.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/H5Z.c b/src/H5Z.c
index a96e783..573ec6b 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -797,25 +797,25 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
* filter struct is reallocated. Set these pointers to ~NULL
* so that we can reset them after reallocating the filters array.
*/
- for(n=0; n<pline->nalloc; ++n) {
+ for(n = 0; n < pline->nalloc; ++n)
if(pline->filter[n].cd_values == pline->filter[n]._cd_values)
pline->filter[n].cd_values = (void *) ~((size_t)NULL);
- }
x.nalloc = MAX(H5Z_MAX_NFILTERS, 2 * pline->nalloc);
- x.filter = H5MM_realloc(pline->filter, x.nalloc*sizeof(x.filter[0]));
+ x.filter = H5MM_realloc(pline->filter, x.nalloc * sizeof(x.filter[0]));
if(NULL == x.filter)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline")
- pline->nalloc = x.nalloc;
- pline->filter = x.filter;
- /* Fix pointers in filters that need to point to their own internal
- * data.
+ /* Fix pointers in previous filters that need to point to their own
+ * internal data.
*/
- for(n=0; n<pline->nalloc; ++n) {
- if(pline->filter[n].cd_values == (void *) ~((size_t) NULL))
- pline->filter[n].cd_values = pline->filter[n]._cd_values;
- }
+ for(n = 0; n < pline->nalloc; ++n)
+ if(x.filter[n].cd_values == (void *) ~((size_t) NULL))
+ x.filter[n].cd_values = x.filter[n]._cd_values;
+
+ /* Point to newly allocated buffer */
+ pline->nalloc = x.nalloc;
+ pline->filter = x.filter;
} /* end if */
/* Add the new filter to the pipeline */