Hi all,
When an error page template file is empty I am getting strange
behaviour, sometimes I am getting an assertion failed, some other cases
crap send to the client instead of an error page.
These problems caused because a MemBuf , in which no data added is not
NULL terminated. I am attaching a patch which terminates an empty MemBuf.
We are consider MemBuf as always NULL terminated, so I believe we must
terminate an empty MemBuf too.
Regards,
Christos
=== modified file 'src/MemBuf.cc'
--- src/MemBuf.cc 2012-11-28 01:13:21 +0000
+++ src/MemBuf.cc 2014-04-07 15:57:46 +0000
@@ -120,40 +120,41 @@
CBDATA_CLASS_INIT(MemBuf);
/** init with defaults */
void
MemBuf::init()
{
init(MEM_BUF_INIT_SIZE, MEM_BUF_MAX_SIZE);
}
/** init with specific sizes */
void
MemBuf::init(mb_size_t szInit, mb_size_t szMax)
{
assert(szInit > 0 && szMax > 0);
buf = NULL;
size = 0;
max_capacity = szMax;
capacity = 0;
stolen = 0;
grow(szInit);
+ terminate();
}
/**
* cleans the mb; last function to call if you do not give .buf away with
* memBufFreeFunc
*/
void
MemBuf::clean()
{
if (isNull()) {
// nothing to do
} else {
assert(buf);
assert(!stolen); /* not frozen */
memFreeBuf(capacity, buf);
buf = NULL;
size = capacity = max_capacity = 0;
}
}