mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-16 12:10:46 +01:00
bugfix/imfile: memory leak in readMode 0
Bug is actually in stream object, but currently exposed only via imfile. Happens when in readMode 0 a partial line is read and no more data is present in the file during that iteration. One partial message is lost in this case. closes https://github.com/rsyslog/rsyslog/issues/2421
This commit is contained in:
parent
fba936b0b1
commit
c55f37ef71
@ -749,7 +749,6 @@ strmReadLine(strm_t *pThis, cstr_t **ppCStr, uint8_t mode, sbool bEscapeLF,
|
||||
{
|
||||
uchar c;
|
||||
uchar finished;
|
||||
rsRetVal readCharRet;
|
||||
DEFiRet;
|
||||
|
||||
ASSERT(pThis != NULL);
|
||||
@ -769,12 +768,7 @@ strmReadLine(strm_t *pThis, cstr_t **ppCStr, uint8_t mode, sbool bEscapeLF,
|
||||
if(mode == 0) {
|
||||
while(c != '\n') {
|
||||
CHKiRet(cstrAppendChar(*ppCStr, c));
|
||||
readCharRet = strmReadChar(pThis, &c);
|
||||
if((readCharRet == RS_RET_TIMED_OUT) ||
|
||||
(readCharRet == RS_RET_EOF) ) { /* end reached without \n? */
|
||||
CHKiRet(rsCStrConstructFromCStr(&pThis->prevLineSegment, *ppCStr));
|
||||
}
|
||||
CHKiRet(readCharRet);
|
||||
CHKiRet(strmReadChar(pThis, &c));
|
||||
}
|
||||
if (trimLineOverBytes > 0 && (uint32_t) cstrLen(*ppCStr) > trimLineOverBytes) {
|
||||
/* Truncate long line at trimLineOverBytes position */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user