Fix ixallocx_prof() size+extra overflow.

Fix ixallocx_prof() to clamp the extra parameter if size+extra would
overflow HUGE_MAXCLASS.
This commit is contained in:
Jason Evans 2015-09-14 22:31:32 -07:00
parent 8f57e3f1ae
commit 4acb6c7ff3

View File

@ -2275,6 +2275,9 @@ ixallocx_prof(tsd_t *tsd, void *ptr, size_t old_usize, size_t size,
prof_tctx_t *old_tctx, *tctx;
old_tctx = prof_tctx_get(ptr);
/* Clamp extra if necessary to avoid (size + extra) overflow. */
if (unlikely(size + extra > HUGE_MAXCLASS))
extra = HUGE_MAXCLASS - size;
/*
* usize isn't knowable before ixalloc() returns when extra is non-zero.
* Therefore, compute its maximum possible value and use that in