Skip to content

Instantly share code, notes, and snippets.

@saidelike
Last active July 6, 2021 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saidelike/7717589b053a63a51e91aebb4d7c8393 to your computer and use it in GitHub Desktop.
Save saidelike/7717589b053a63a51e91aebb4d7c8393 to your computer and use it in GitHub Desktop.
//glibc_2.17-322.el7_9/malloc/malloc.c
static void*
_int_malloc(mstate av, size_t bytes)
{
...
for(;;) {
int iters = 0;
while ( (victim = unsorted_chunks(av)->bk) != unsorted_chunks(av)) {
bck = victim->bk;
if (__builtin_expect (victim->size <= 2 * SIZE_SZ, 0)
|| __builtin_expect (victim->size > av->system_mem, 0))
{
mutex_unlock(&av->mutex);
malloc_printerr (check_action, "malloc(): memory corruption",
[c1] chunk2mem (victim), av);
mutex_lock(&av->mutex);
}
size = chunksize(victim);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment