aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/gfx
diff options
context:
space:
mode:
authorPaul Gilbert2010-10-18 10:26:27 +0000
committerPaul Gilbert2010-10-18 10:26:27 +0000
commitae63e206618821e3e2550927851353ac6aafaae6 (patch)
treedc1a275c03ad326b5c0b4e59ae1517f89fd24536 /engines/sword25/gfx
parentada933c2ad25bce6200d0edfb0df73ecca17b764 (diff)
downloadscummvm-rg350-ae63e206618821e3e2550927851353ac6aafaae6.tar.gz
scummvm-rg350-ae63e206618821e3e2550927851353ac6aafaae6.tar.bz2
scummvm-rg350-ae63e206618821e3e2550927851353ac6aafaae6.zip
SWORD25: Fix for Valgrind identified errors
svn-id: r53563
Diffstat (limited to 'engines/sword25/gfx')
-rw-r--r--engines/sword25/gfx/image/b25sloader.cpp11
1 files changed, 7 insertions, 4 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;