diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index b3d31ac1c97..6e4fac544e2 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -554,7 +554,6 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { curCel->index_data = (byte *)malloc(celInfo->width * celInfo->height); byte *tmpBuffer = guiView->getBitmap(i, j); memcpy(curCel->index_data, tmpBuffer, celInfo->width * celInfo->height); - delete tmpBuffer; curCel->flags = 0; curCel->width = celInfo->width; curCel->height = celInfo->height; @@ -569,6 +568,8 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { } } + delete guiView; + if (!res) { res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t)); res->scaled_data.view = NULL; diff --git a/engines/sci/gui/gui_view.cpp b/engines/sci/gui/gui_view.cpp index 1c3072eaedb..83f63fb8a84 100644 --- a/engines/sci/gui/gui_view.cpp +++ b/engines/sci/gui/gui_view.cpp @@ -40,6 +40,15 @@ SciGuiView::SciGuiView(ResourceManager *resMan, SciGuiScreen *screen, SciGuiPale } SciGuiView::~SciGuiView() { + // Iterate through the loops + for (uint16 loopNum = 0; loopNum < _loopCount; loopNum++) { + // and through the cells of each loop + for (uint16 celNum = 0; celNum < _loop[loopNum].celCount; celNum++) { + delete _loop[loopNum].cel[celNum].rawBitmap; + } + delete _loop[loopNum].cel; + } + delete _loop; } static const byte EGAMappingDefault[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };