From 5cb9483a790fcb81676be9d287178b3040667d20 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 10 Mar 2010 15:28:54 +0000 Subject: Guard call to the allocator in deallocate() by checking if the alloc pointer was actually set. Otherwise, the following problem could occur if an allocator could not be found: init() will call Allocator::get, which throws an exception init() is called from the constructor of the subclasses (MemoryVector, etc) Since the constructor of MemoryRegion has already finished, its destructor will be called. ~MemoryRegion will call deallocate() deallocate() will then access a NULL pointer By guarding the call, the exception is propagated correctly. --- src/alloc/secmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/alloc') diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h index fd08c6198..42b5c7a2d 100644 --- a/src/alloc/secmem.h +++ b/src/alloc/secmem.h @@ -210,7 +210,7 @@ class MemoryRegion } void deallocate(T* p, u32bit n) - { alloc->deallocate(p, sizeof(T)*n); } + { if(alloc && p && n) alloc->deallocate(p, sizeof(T)*n); } T* buf; u32bit used; -- cgit v1.2.3