From a16114866a8e52a4fc8057d5c3123e2dc5c0ceab Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Thu, 25 May 2017 18:15:41 -0700 Subject: [PATCH] Fix OOM paths in extent_grow_retained(). --- src/extent.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/extent.c b/src/extent.c index fee8198e..7359a558 100644 --- a/src/extent.c +++ b/src/extent.c @@ -1046,10 +1046,15 @@ extent_grow_retained(tsdn_t *tsdn, arena_t *arena, extent_init(extent, arena, ptr, alloc_size, false, NSIZES, arena_extent_sn_next(arena), extent_state_active, zeroed, committed); - if (ptr == NULL || extent_register_no_gdump_add(tsdn, extent)) { + if (ptr == NULL) { extent_dalloc(tsdn, arena, extent); return NULL; } + if (extent_register_no_gdump_add(tsdn, extent)) { + extents_leak(tsdn, arena, r_extent_hooks, + &arena->extents_retained, extent); + return NULL; + } size_t leadsize = ALIGNMENT_CEILING((uintptr_t)ptr, PAGE_CEILING(alignment)) - (uintptr_t)ptr; @@ -1070,7 +1075,8 @@ extent_grow_retained(tsdn_t *tsdn, arena_t *arena, leadsize, NSIZES, false, esize + trailsize, szind, slab); if (extent == NULL) { extent_deregister(tsdn, lead); - extents_leak(tsdn, arena, r_extent_hooks, false, lead); + extents_leak(tsdn, arena, r_extent_hooks, + &arena->extents_retained, lead); return NULL; } extent_record(tsdn, arena, r_extent_hooks,