Don't use the main arena in retry path if it is corrupt

If allocation on a non-main arena fails, the main arena is used
without checking to see if it is corrupt.  Add a check that avoids the
main arena if it is corrupt.

	* malloc/arena.c (arena_get_retry): Don't use main_arena if it is
	corrupt.
This commit is contained in:
Siddhesh Poyarekar 2015-08-24 14:33:07 +05:30
parent 92a9b22d70
commit c3b9ef8dfc
2 changed files with 7 additions and 0 deletions

View File

@ -1,5 +1,8 @@
2015-08-24 Siddhesh Poyarekar <siddhesh@redhat.com>
* malloc/arena.c (arena_get_retry): Don't use main_arena if it
is corrupt.
* malloc/arena.c (arena_get2): Drop unused argument.
(arena_lock): Adjust.
(arena_get_retry): Likewise.

View File

@ -909,6 +909,10 @@ arena_get_retry (mstate ar_ptr, size_t bytes)
if (ar_ptr != &main_arena)
{
(void) mutex_unlock (&ar_ptr->mutex);
/* Don't touch the main arena if it is corrupt. */
if (arena_is_corrupt (&main_arena))
return NULL;
ar_ptr = &main_arena;
(void) mutex_lock (&ar_ptr->mutex);
}