Add opt-in panic for KMessage buffer overflow

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43215 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2011-11-07 19:19:34 +00:00
parent 5b78a98745
commit 40287cba78

View File

@ -962,8 +962,16 @@ KMessage::_AllocateSpace(int32 size, bool alignAddress, bool alignSize,
} else {
if (newSize > fBufferCapacity) {
// if we don't own the buffer, we can't resize it
if (!(fFlags & KMESSAGE_OWNS_BUFFER))
if (!(fFlags & KMESSAGE_OWNS_BUFFER)) {
#ifdef _KERNEL_MODE && 0
// optional debugging to find insufficiently sized KMessage
// buffers (e.g. for in-kernel notifications)
panic("KMessage: out of space: available: %" B_PRId32
", needed: %" B_PRId32 "\n", fBufferCapacity, newSize);
#endif
return B_BUFFER_OVERFLOW;
}
int32 newCapacity = _CapacityFor(newSize);
void* newBuffer = realloc(fBuffer, newCapacity);
if (!newBuffer)