libluna/Heap: Crash the kernel (but not userspace) on invalid frees
This makes them way easier to catch and forces us to get those out of the way.
This commit is contained in:
parent
c376477080
commit
e8a401efc2
@ -249,13 +249,21 @@ Result<void> free_impl(void* ptr)
|
||||
else
|
||||
dbgln("ERROR: Attempt to free memory at %p, which wasn't allocated with malloc", ptr);
|
||||
|
||||
#ifdef USE_FREESTANDING
|
||||
fail("Call to free_impl() with an invalid argument (double-free or erroneous deallocation)");
|
||||
#else
|
||||
return err(EFAULT);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (is_block_free(block))
|
||||
{
|
||||
dbgln("ERROR: Attempt to free memory at %p, which was already freed", ptr);
|
||||
#ifdef USE_FREESTANDING
|
||||
fail("Call to free_impl() with a pointer to freed memory (probably double-free)");
|
||||
#else
|
||||
return err(EFAULT);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
block->status &= ~BLOCK_USED;
|
||||
|
Loading…
Reference in New Issue
Block a user