Skip to content

Instantly share code, notes, and snippets.

@tomprince
Created April 5, 2011 14:38
Show Gist options
  • Save tomprince/903716 to your computer and use it in GitHub Desktop.
Save tomprince/903716 to your computer and use it in GitHub Desktop.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a52c538..eab017b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,18 +6,6 @@ endif(COMMAND cmake_policy)
# allow empty else and endif constructs (available by default since 2.6.0)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
-# prevent in-source builds
-IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
- MESSAGE(FATAL_ERROR "
- CMake generation for this project is not allowed within the source directory!
- Remove the CMakeCache.txt file and try again from another folder, e.g.:
- rm CMakeCache.txt
- mkdir build
- cd build
- cmake .."
- )
-ENDIF()
-
# If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition
# and dump it in the cache along with proper documentation, otherwise set CMAKE_BUILD_TYPE
# to Release prior to calling PROJECT()
diff --git a/gemrb/core/FileCache.cpp b/gemrb/core/FileCache.cpp
index 86b0970..4d3724f 100644
--- a/gemrb/core/FileCache.cpp
+++ b/gemrb/core/FileCache.cpp
@@ -44,7 +44,10 @@ DataStream* CacheCompressedStream(DataStream *stream, const char* filename, int
}
PluginHolder<Compressor> comp(PLUGIN_COMPRESSION_ZLIB);
- comp->Decompress(&out, stream, length);
+ if (comp->Decompress(&out, stream, length) != GEM_OK)
+ return NULL;
+ } else {
+ stream->Seek(length, GEM_CURRENT_POS);
}
return FileStream::OpenFile(path);
}
diff --git a/gemrb/plugins/BIFImporter/BIFImporter.cpp b/gemrb/plugins/BIFImporter/BIFImporter.cpp
index 6808f21..8bd0a5d 100644
--- a/gemrb/plugins/BIFImporter/BIFImporter.cpp
+++ b/gemrb/plugins/BIFImporter/BIFImporter.cpp
@@ -61,6 +61,10 @@ int BIFImporter::DecompressSaveGame(DataStream *compressed)
do {
ieDword fnlen, complen, declen;
compressed->ReadDword( &fnlen );
+ if (!fnlen) {
+ printMessage("BIFImporter", "Corrupt Save Detected\n", RED);
+ return GEM_ERROR;
+ }
char* fname = ( char* ) malloc( fnlen );
compressed->Read( fname, fnlen );
strlwr(fname);
@@ -69,6 +73,8 @@ int BIFImporter::DecompressSaveGame(DataStream *compressed)
printf( "Decompressing %s\n", fname );
DataStream* cached = CacheCompressedStream(compressed, fname, complen);
free( fname );
+ if (!cached)
+ return GEM_ERROR;
delete cached;
Current = compressed->Remains();
//starting at 20% going up to 70%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment