diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-02-25 14:46:07 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-02-25 14:46:07 +0100 |
commit | 74a71e798efd58e20cc150b04de2613bf518eed4 (patch) | |
tree | 5b0b04e1b44912c6a143b180dead5b62e4390343 /runtime/batch.h | |
parent | a8760241a30dc2618c53c569d23acdec1e06908e (diff) | |
parent | 5b1cd3330196c5ffa2b8695798946aa2441b7e84 (diff) | |
download | rsyslog-74a71e798efd58e20cc150b04de2613bf518eed4.tar.gz rsyslog-74a71e798efd58e20cc150b04de2613bf518eed4.tar.xz rsyslog-74a71e798efd58e20cc150b04de2613bf518eed4.zip |
Merge branch 'v5-beta'
Conflicts:
ChangeLog
configure.ac
doc/manual.html
Diffstat (limited to 'runtime/batch.h')
-rw-r--r-- | runtime/batch.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/batch.h b/runtime/batch.h index d0504f2b..944889bd 100644 --- a/runtime/batch.h +++ b/runtime/batch.h @@ -136,11 +136,16 @@ batchIsValidElem(batch_t *pBatch, int i) { /* copy one batch element to another. * This creates a complete duplicate in those cases where * it is needed. Use duplication only when absolutely necessary! + * Note that all working fields are reset to zeros. If that were + * not done, we would have potential problems with invalid + * or double pointer frees. * rgerhards, 2010-06-10 */ static inline void batchCopyElem(batch_obj_t *pDest, batch_obj_t *pSrc) { - memcpy(pDest, pSrc, sizeof(batch_obj_t)); + memset(pDest, 0, sizeof(batch_obj_t)); + pDest->pUsrp = pSrc->pUsrp; + pDest->state = pSrc->state; } @@ -171,6 +176,7 @@ batchFree(batch_t *pBatch) { static inline rsRetVal batchInit(batch_t *pBatch, int maxElem) { DEFiRet; + pBatch->iDoneUpTo = 0; pBatch->maxElem = maxElem; CHKmalloc(pBatch->pElem = calloc((size_t)maxElem, sizeof(batch_obj_t))); // TODO: replace calloc by inidividual writes? |