diff options
author | lloyd <[email protected]> | 2010-03-10 15:28:54 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-10 15:28:54 +0000 |
commit | 5cb9483a790fcb81676be9d287178b3040667d20 (patch) | |
tree | e688f41896b4a398d736ecfa7cd56b5c1588b1e2 /src/alloc | |
parent | e34b9693d203dcb17e396ba58c00489c7d02a98c (diff) |
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.
Diffstat (limited to 'src/alloc')
-rw-r--r-- | src/alloc/secmem.h | 2 |
1 files changed, 1 insertions, 1 deletions
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; |