mirror of
https://github.com/OISF/suricata.git
synced 2026-05-28 04:32:12 -04:00
lua: enforce allocation limit on first alloc
Instead of just on re-alloc. Ticket: #8507
This commit is contained in:
parent
24527d662a
commit
2d6c3213ae
1 changed files with 7 additions and 0 deletions
|
|
@ -64,6 +64,13 @@ static void *LuaAlloc(void *ud, void *ptr, size_t osize, size_t nsize)
|
|||
return NULL;
|
||||
} else if (ptr == NULL) {
|
||||
/* Allocating new data. */
|
||||
if (ctx->alloc_limit != 0 && ctx->alloc_bytes + nsize > ctx->alloc_limit) {
|
||||
/* This request will exceed the allocation limit. Act as
|
||||
* though allocation failed. */
|
||||
ctx->memory_limit_error = true;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *nptr = SCRealloc(ptr, nsize);
|
||||
if (nptr != NULL) {
|
||||
ctx->alloc_bytes += nsize;
|
||||
|
|
|
|||
Loading…
Reference in a new issue