Skip to content
Snippets Groups Projects
  • Richard Earnshaw's avatar
    29f6f2d2
    Don't allow the pool allocator to be configured to allocate zero-sized objects · 29f6f2d2
    Richard Earnshaw authored
    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 <TBlockAllocator>::initialize):
    	Assert that the allocation size is not zero.
    
    From-SVN: r265620
    29f6f2d2
    History
    Don't allow the pool allocator to be configured to allocate zero-sized objects
    Richard Earnshaw authored
    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 <TBlockAllocator>::initialize):
    	Assert that the allocation size is not zero.
    
    From-SVN: r265620