From: Richard Earnshaw Date: Tue, 30 Oct 2018 11:33:24 +0000 (+0000) Subject: Don't allow the pool allocator to be configured to allocate zero-sized objects X-Git-Tag: basepoints/gcc-10~3440 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29f6f2d244c77dd7ae5a86b3bf7cb18fd953168f;p=thirdparty%2Fgcc.git Don't allow the pool allocator to be configured to allocate zero-sized objects PR bootstrap/87747 would have been significantly easier to track down if the pool allocator had faulted an attempt to configure it to allocate zero-sized objects. Instead, this slipped through and we later hit memory corruption when the assumed size turned out to be different to the configured size. While, theoretically, there might be a use case for this, it seems unlikely to me that GCC would have such a use. So this patch adds a checking assert that the object size is not zero. * alloc-pool.h (base_pool_allocator ::initialize): Assert that the allocation size is not zero. From-SVN: r265620 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da7b998f39af..c07d3ad96680 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-10-30 Richard Earnshaw + + * alloc-pool.h (base_pool_allocator ::initialize): + Assert that the allocation size is not zero. + 2018-10-30 Richard Biener PR tree-optimization/87800 diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h index c0a129205582..d2ee00057611 100644 --- a/gcc/alloc-pool.h +++ b/gcc/alloc-pool.h @@ -256,6 +256,7 @@ base_pool_allocator ::initialize () size_t size = m_size; gcc_checking_assert (m_name); + gcc_checking_assert (m_size); /* Make size large enough to store the list header. */ if (size < sizeof (allocation_pool_list*))