diff mbox

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

Message ID 1440402236-1324-1-git-send-email-siddhesh@redhat.com
State New
Headers show

Commit Message

Siddhesh Poyarekar Aug. 24, 2015, 7:43 a.m. UTC
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.
---
 malloc/arena.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Andreas Schwab Aug. 24, 2015, 8:04 a.m. UTC | #1
"Siddhesh Poyarekar" <siddhesh@redhat.com> writes:

> 	* malloc/arena.c (arena_get_retry): Don't use main_arena if it is
> 	corrupt.

Ok.

Andreas.
diff mbox

Patch

diff --git a/malloc/arena.c b/malloc/arena.c
index 11912e9..060eb95 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -914,6 +914,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);
     }