[llvm] r189340 - Add an assertion to the fixed-size allocator to ensure that we don't request

Joey Gouly joey.gouly at arm.com
Tue Aug 27 04:20:14 PDT 2013


Author: joey
Date: Tue Aug 27 06:20:13 2013
New Revision: 189340

URL: http://llvm.org/viewvc/llvm-project?rev=189340&view=rev
Log:
Add an assertion to the fixed-size allocator to ensure that we don't request
an allocation that is greater than what we will actually allocate.

Patch by Artyom Skrobov!

Modified:
    llvm/trunk/include/llvm/Support/RecyclingAllocator.h

Modified: llvm/trunk/include/llvm/Support/RecyclingAllocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/RecyclingAllocator.h?rev=189340&r1=189339&r2=189340&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/RecyclingAllocator.h (original)
+++ llvm/trunk/include/llvm/Support/RecyclingAllocator.h Tue Aug 27 06:20:13 2013
@@ -60,9 +60,10 @@ public:
 }
 
 template<class AllocatorType, class T, size_t Size, size_t Align>
-inline void *operator new(size_t,
+inline void *operator new(size_t size,
                           llvm::RecyclingAllocator<AllocatorType,
                                                    T, Size, Align> &Allocator) {
+  assert(size <= Size && "allocation size exceeded");
   return Allocator.Allocate();
 }
 





More information about the llvm-commits mailing list