Buflib_init Bugfix Minsize

when buflib_init is called with a buffer smaller than
sizeof(union buflib_data); size will be zero
Later when the alloc fails buflib will keep try to free items
in order to satisify the request this crashes in the sim
I suspect this behavior holds true on device as well
but I havent verified this as of yet.

patch adds minimal overhead to the buflib and panics when the size is too small

Change-Id: I46e510367fc1cac19ce01ee6f92d8cf0d65ef914
This commit is contained in:
William Wilgus 2020-06-27 23:32:45 -04:00
parent 7d005335ba
commit 8577d5aea3
1 changed files with 6 additions and 0 deletions

View File

@ -123,6 +123,12 @@ buflib_init(struct buflib_context *ctx, void *buf, size_t size)
*/
ctx->alloc_end = bd_buf;
ctx->compact = true;
if (size == 0)
{
BPANICF("buflib_init error (CTX:%p, %zd bytes):\n", ctx,
(ctx->handle_table - ctx->buf_start) * sizeof(union buflib_data));
}
}
bool buflib_context_relocate(struct buflib_context *ctx, void *buf)