[Scummvm-git-logs] scummvm master -> a2f1700fc3ec7bf3a01fceac80ae5cbed813d5b0

lephilousophe lephilousophe at users.noreply.github.com
Sun Jun 9 12:48:35 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a2f1700fc3 CRYOMNI3D: Fix various memory errors


Commit: a2f1700fc3ec7bf3a01fceac80ae5cbed813d5b0
    https://github.com/scummvm/scummvm/commit/a2f1700fc3ec7bf3a01fceac80ae5cbed813d5b0
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2019-06-09T12:46:58+02:00

Commit Message:
CRYOMNI3D: Fix various memory errors

Changed paths:
    engines/cryomni3d/versailles/documentation.cpp
    engines/cryomni3d/versailles/documentation.h
    engines/cryomni3d/versailles/engine.cpp
    engines/cryomni3d/versailles/menus.cpp


diff --git a/engines/cryomni3d/versailles/documentation.cpp b/engines/cryomni3d/versailles/documentation.cpp
index c0acbc8..a33e992 100644
--- a/engines/cryomni3d/versailles/documentation.cpp
+++ b/engines/cryomni3d/versailles/documentation.cpp
@@ -280,6 +280,12 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
 	Image::BitmapDecoder bmpDecoder;
 	Common::File file;
 
+	Image::ImageDecoder *imageDecoder = _engine->loadHLZ("SOM1.HLZ");
+	if (!imageDecoder) {
+		return "";
+	}
+	const Graphics::Surface *bgFrame = imageDecoder->getSurface();
+
 	for (uint i = 0; i < ARRAYSIZE(categories); i++) {
 		if (!categories[i].bmp) {
 			// No BMP to load
@@ -296,12 +302,6 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
 		file.close();
 	}
 
-	Image::ImageDecoder *imageDecoder = _engine->loadHLZ("SOM1.HLZ");
-	if (!imageDecoder) {
-		return "";
-	}
-	const Graphics::Surface *bgFrame = imageDecoder->getSurface();
-
 	Graphics::ManagedSurface docSurface;
 	docSurface.create(bgFrame->w, bgFrame->h, bgFrame->format);
 	docSurface.blitFrom(*bgFrame);
@@ -411,6 +411,10 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
 
 	_engine->showMouse(false);
 
+	for (uint i = 0; i < ARRAYSIZE(categories); i++) {
+		categories[i].highlightedImg.free();
+	}
+
 	delete imageDecoder;
 
 	if (selectedBox == 7) {
@@ -906,6 +910,12 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
 	Image::BitmapDecoder bmpDecoder;
 	Common::File file;
 
+	Image::ImageDecoder *imageDecoder = _engine->loadHLZ("PLANGR.HLZ");
+	if (!imageDecoder) {
+		return "";
+	}
+	const Graphics::Surface *bgFrame = imageDecoder->getSurface();
+
 	for (uint i = 0; i < ARRAYSIZE(areas); i++) {
 		if (areas[i].bmp) {
 			if (!file.open(areas[i].bmp)) {
@@ -938,12 +948,6 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
 	boxes.setupBox(ARRAYSIZE(areas), 639 - _sprites->getCursor(105).getWidth(),
 	               479 - _sprites->getCursor(105).getHeight(), 640, 480);
 
-	Image::ImageDecoder *imageDecoder = _engine->loadHLZ("PLANGR.HLZ");
-	if (!imageDecoder) {
-		return "";
-	}
-	const Graphics::Surface *bgFrame = imageDecoder->getSurface();
-
 	Graphics::ManagedSurface mapSurface;
 	mapSurface.create(bgFrame->w, bgFrame->h, bgFrame->format);
 	mapSurface.blitFrom(*bgFrame);
@@ -1052,6 +1056,10 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
 
 	_engine->showMouse(false);
 
+	for (uint i = 0; i < ARRAYSIZE(areas); i++) {
+		areas[i].highlightedImg.free();
+	}
+
 	delete imageDecoder;
 
 	if (selectedBox == ARRAYSIZE(areas)) {
@@ -1538,6 +1546,8 @@ void Versailles_Documentation::drawRecordData(Graphics::ManagedSurface &surface,
 
 	_fontManager->setupBlock(blockCaption);
 	_fontManager->displayBlockText(caption);
+
+	delete imageDecoder;
 }
 
 void Versailles_Documentation::setupRecordBoxes(bool inDocArea, MouseBoxes &boxes) {
diff --git a/engines/cryomni3d/versailles/documentation.h b/engines/cryomni3d/versailles/documentation.h
index a1559f8..1808956 100644
--- a/engines/cryomni3d/versailles/documentation.h
+++ b/engines/cryomni3d/versailles/documentation.h
@@ -41,7 +41,7 @@ class Versailles_Documentation {
 public:
 	Versailles_Documentation() : _engine(nullptr), _fontManager(nullptr), _messages(nullptr),
 		_linksData(nullptr), _linksSize(0) { }
-	~Versailles_Documentation() { delete _linksData; }
+	~Versailles_Documentation() { delete [] _linksData; }
 
 	void init(const Sprites *sprites, FontManager *fontManager, const Common::StringArray *messages,
 	          CryOmni3DEngine *engine);
diff --git a/engines/cryomni3d/versailles/engine.cpp b/engines/cryomni3d/versailles/engine.cpp
index ab9318f..86f214d 100644
--- a/engines/cryomni3d/versailles/engine.cpp
+++ b/engines/cryomni3d/versailles/engine.cpp
@@ -1607,7 +1607,7 @@ void CryOmni3DEngine_Versailles::playInGameVideo(const Common::String &filename,
 	unlockPalette();
 	if (restoreCursorPalette) {
 		// Restore cursors colors as 2 first ones may have been erased by the video
-		setPalette(&_cursorPalette[3 * 240], 240, 248);
+		setPalette(&_cursorPalette[3 * 240], 240, 8);
 		// WORKAROUND: Don't mess with mouse when not restoring cursors palette
 		showMouse(true);
 	}
diff --git a/engines/cryomni3d/versailles/menus.cpp b/engines/cryomni3d/versailles/menus.cpp
index 6da7a85..6ce02f6 100644
--- a/engines/cryomni3d/versailles/menus.cpp
+++ b/engines/cryomni3d/versailles/menus.cpp
@@ -1073,6 +1073,8 @@ void CryOmni3DEngine_Versailles::displayCredits() {
 		}
 	}
 	showMouse(true);
+
+	delete imageDecoder;
 }
 
 } // End of namespace Versailles





More information about the Scummvm-git-logs mailing list