diff options
| author | Julien | 2011-06-04 03:43:16 +0800 |
|---|---|---|
| committer | Julien | 2011-06-23 15:11:36 +0800 |
| commit | 2f200ac49322ff8ccd13c5e8b7a22abbf6ff2610 (patch) | |
| tree | d22f6efae6ac234cbe0b73783aa8a8962a84a3b6 /engines/lure | |
| parent | a8b13e8a6be900995c85f08fd527750e2620c215 (diff) | |
| download | scummvm-rg350-2f200ac49322ff8ccd13c5e8b7a22abbf6ff2610.tar.gz scummvm-rg350-2f200ac49322ff8ccd13c5e8b7a22abbf6ff2610.tar.bz2 scummvm-rg350-2f200ac49322ff8ccd13c5e8b7a22abbf6ff2610.zip | |
ANALYSIS: Fix potential memory leak when using realloc
When reallocation is unsuccessful, the passed buffer is not freed. In this case, assigning the result (NULL) will result in a leak of the original memory buffer.
See http://msdn.microsoft.com/en-us/library/kkedhy7c.aspx
Diffstat (limited to 'engines/lure')
| -rw-r--r-- | engines/lure/memory.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/engines/lure/memory.cpp b/engines/lure/memory.cpp index c5c28fa8bc..137a8f6bee 100644 --- a/engines/lure/memory.cpp +++ b/engines/lure/memory.cpp @@ -93,8 +93,12 @@ void MemoryBlock::copyFrom(const byte *src, uint32 srcPos, uint32 destPos, uint3 void MemoryBlock::reallocate(uint32 size1) { _size = size1; - _data = (byte *) realloc(_data, size1); - if (!_data) error ("Failed reallocating memory block"); + + byte *tmp = (byte *) realloc(_data, size1); + if (!tmp) + error ("[MemoryBlock::reallocate] Failed reallocating memory block"); + + _data = tmp; } } // End of namespace Lure |
