diff options
author | Max Horn | 2003-03-03 23:57:10 +0000 |
---|---|---|
committer | Max Horn | 2003-03-03 23:57:10 +0000 |
commit | 423f26bc27979eb3f6d03082bae991a103d73fbd (patch) | |
tree | c38cde8cfedbdfcb257e08ff4ff1b89a78db700e | |
parent | 405b6fd0513844ca97ab10f4fcbb21ccc14a59f5 (diff) | |
download | scummvm-rg350-423f26bc27979eb3f6d03082bae991a103d73fbd.tar.gz scummvm-rg350-423f26bc27979eb3f6d03082bae991a103d73fbd.tar.bz2 scummvm-rg350-423f26bc27979eb3f6d03082bae991a103d73fbd.zip |
fix double free bug
svn-id: r6679
-rw-r--r-- | scumm/nut_renderer.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/scumm/nut_renderer.cpp b/scumm/nut_renderer.cpp index 89cb4d1b31..76f317e6e4 100644 --- a/scumm/nut_renderer.cpp +++ b/scumm/nut_renderer.cpp @@ -30,8 +30,10 @@ NutRenderer::NutRenderer(Scumm *vm) { } NutRenderer::~NutRenderer() { - if (_dataSrc != NULL) + if (_dataSrc != NULL) { free(_dataSrc); + _dataSrc = NULL; + } } void NutRenderer::decodeCodec44(byte *dst, byte *src, uint32 length) { @@ -84,8 +86,10 @@ bool NutRenderer::loadFont(const char *filename, const char *dir) { return false; } - if (_dataSrc != NULL) + if (_dataSrc != NULL) { free(_dataSrc); + _dataSrc = NULL; + } uint32 length = file.readUint32BE(); _dataSrc = (byte *)malloc(length); @@ -95,6 +99,7 @@ bool NutRenderer::loadFont(const char *filename, const char *dir) { if (READ_BE_UINT32(_dataSrc) != 'AHDR') { debug(2, "NutRenderer::loadFont() there is no AHDR chunk in font header"); free(_dataSrc); + _dataSrc = NULL; return false; } @@ -110,12 +115,14 @@ bool NutRenderer::loadFont(const char *filename, const char *dir) { else { debug(2, "NutRenderer::loadFont() there is no FRME chunk"); free(_dataSrc); + _dataSrc = NULL; return false; } } else { debug(2, "NutRenderer::loadFont() there is no FOBJ chunk in FRME chunk"); free(_dataSrc); + _dataSrc = NULL; return false; } } |