Fix debug assertion in cache

The call to gwbuf_length will fail if the pointed to buffer isn't the head
of the chain. To prevent this, the length is calculated before the buffer
is appended.

Also fixed the use of gwbuf_append. The return value should be assigned
and the code shouldn't reply on the value passed to the function being
correct.
This commit is contained in:
Markus Mäkelä 2020-07-02 14:32:51 +03:00
parent 7ad3485892
commit ba289dc589
No known key found for this signature in database
GPG Key ID: 5CE746D557ACC499

View File

@ -358,10 +358,11 @@ int CacheFilterSession::clientReply(GWBUF* pData)
if (m_res.pData)
{
gwbuf_append(m_res.pData, pData);
auto len = gwbuf_length(pData); // pData may be a chain, so not GWBUF_LENGTH().
m_res.pData = gwbuf_append(m_res.pData, pData);
m_res.pData_last = pData;
m_res.offset_last = m_res.length;
m_res.length += gwbuf_length(pData); // pData may be a chain, so not GWBUF_LENGTH().
m_res.length += len;
}
else
{