summaryrefslogtreecommitdiffstats
path: root/runtime/batch.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-02-25 14:14:17 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-02-25 14:14:17 +0100
commit1ef709cc97d54f74d3fdeb83788cc4b01f4c6a2a (patch)
treec30642efb93d6750a5939ac9d28ee78ef41a2cd0 /runtime/batch.h
parentf46fa5ca003b55702107e170a2868ed0120246c7 (diff)
downloadrsyslog-1ef709cc97d54f74d3fdeb83788cc4b01f4c6a2a.tar.gz
rsyslog-1ef709cc97d54f74d3fdeb83788cc4b01f4c6a2a.tar.xz
rsyslog-1ef709cc97d54f74d3fdeb83788cc4b01f4c6a2a.zip
bugfix: fixed a memory leak and potential abort condition
this could happen if multiple rulesets were used and some output batches contained messages belonging to more than one ruleset. fixes: http://bugzilla.adiscon.com/show_bug.cgi?id=226 fixes: http://bugzilla.adiscon.com/show_bug.cgi?id=218
Diffstat (limited to 'runtime/batch.h')
-rw-r--r--runtime/batch.h8
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?