summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2017-03-13 22:16:44 +0000
committerpeter1138 <peter1138@openttd.org>2017-03-13 22:16:44 +0000
commitff26c6393e3da796ab14a53462e423909752f68d (patch)
treeffb7f68bb0f131a6e48e094d0c644721912ce69e
parent5e728da075e5959808c6e1b52589fd2c0c0bea63 (diff)
downloadopenttd-ff26c6393e3da796ab14a53462e423909752f68d.tar.xz
(svn r27793) -Fix [FS#6450]: Use of uninitialised variable cause lzo to fail. Add check for error status.
-rw-r--r--src/saveload/saveload.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 5a09906bd..dfa3be721 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -1994,7 +1994,7 @@ struct LZOLoadFilter : LoadFilter {
byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32) * 2];
uint32 tmp[2];
uint32 size;
- lzo_uint len;
+ lzo_uint len = ssize;
/* Read header*/
if (this->chain->Read((byte*)tmp, sizeof(tmp)) != sizeof(tmp)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE, "File read failed");
@@ -2016,7 +2016,8 @@ struct LZOLoadFilter : LoadFilter {
if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlErrorCorrupt("Bad checksum");
/* Decompress */
- lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, NULL);
+ int ret = lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, NULL);
+ if (ret != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
return len;
}
};