From ae63e206618821e3e2550927851353ac6aafaae6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Oct 2010 10:26:27 +0000 Subject: SWORD25: Fix for Valgrind identified errors svn-id: r53563 --- engines/sword25/gfx/image/b25sloader.cpp | 11 +++++++---- engines/sword25/package/packagemanager.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/engines/sword25/gfx/image/b25sloader.cpp b/engines/sword25/gfx/image/b25sloader.cpp index 513e74ccea..393d0e2d80 100644 --- a/engines/sword25/gfx/image/b25sloader.cpp +++ b/engines/sword25/gfx/image/b25sloader.cpp @@ -49,22 +49,25 @@ namespace { static Common::String LoadString(Common::ReadStream &In, uint MaxSize = 999) { Common::String Result; - char ch = (char)In.readByte(); - while ((ch != '\0') && (ch != ' ')) { + while (!In.eos() && (Result.size() < MaxSize)) { + char ch = (char)In.readByte(); + if ((ch == '\0') || (ch == ' ')) + break; + Result += ch; - if (Result.size() >= MaxSize) break; - ch = (char)In.readByte(); } return Result; } uint FindEmbeddedPNG(const byte *FileDataPtr, uint FileSize) { + assert(FileSize >= 100); if (memcmp(FileDataPtr, "BS25SAVEGAME", 12)) return 0; // Read in the header Common::MemoryReadStream stream(FileDataPtr, FileSize); + stream.seek(0, SEEK_SET); // Headerinformationen der Spielstandes einlesen. uint compressedGamedataSize; diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 063844f3ba..c80f0c6c84 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -160,7 +160,7 @@ byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr) return 0; } - if (*fileSizePtr) + if (fileSizePtr) *fileSizePtr = file->size(); byte *buffer = new byte[file->size()]; -- cgit v1.2.3