Skip to content
Snippets Groups Projects
Commit 08835b4e authored by Avi Kivity's avatar Avi Kivity Committed by Pekka Enberg
Browse files

bsd: don't cache uma allocations if CONF_debug_memory


Caching allocations can hide use-after-free bugs.

Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 3c16063a
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
void* uma_zone::cache::alloc() void* uma_zone::cache::alloc()
{ {
if (len) { if (len && CONF_debug_memory) {
return a[--len]; return a[--len];
} }
return nullptr; return nullptr;
...@@ -22,7 +22,7 @@ void* uma_zone::cache::alloc() ...@@ -22,7 +22,7 @@ void* uma_zone::cache::alloc()
bool uma_zone::cache::free(void* obj) bool uma_zone::cache::free(void* obj)
{ {
if (len < max_size) { if (len < max_size && CONF_debug_memory) {
a[len++] = obj; a[len++] = obj;
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment