diff options
author | Mattes D <github@xoft.cz> | 2014-04-27 17:00:37 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-04-27 17:00:37 +0200 |
commit | a0f6149d0551c532896db2b920333718f68888d8 (patch) | |
tree | 27826e519c342e395e535190201a47e4a65e74e0 /src/WorldStorage/WSSCompact.cpp | |
parent | Merge pull request #941 from archshift/master (diff) | |
parent | Fixed unitialized member in gZipFile (CID 43673) (diff) | |
download | cuberite-a0f6149d0551c532896db2b920333718f68888d8.tar cuberite-a0f6149d0551c532896db2b920333718f68888d8.tar.gz cuberite-a0f6149d0551c532896db2b920333718f68888d8.tar.bz2 cuberite-a0f6149d0551c532896db2b920333718f68888d8.tar.lz cuberite-a0f6149d0551c532896db2b920333718f68888d8.tar.xz cuberite-a0f6149d0551c532896db2b920333718f68888d8.tar.zst cuberite-a0f6149d0551c532896db2b920333718f68888d8.zip |
Diffstat (limited to 'src/WorldStorage/WSSCompact.cpp')
-rw-r--r-- | src/WorldStorage/WSSCompact.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index c07c9e96f..359bac4a8 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -468,7 +468,15 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ for (int i = 0; i < NumChunks; i++) { sChunkHeader * Header = new sChunkHeader; - READ(*Header); + + // Here we do not use the READ macro, as it does not free the resources + // allocated with new in case of error. + if (f.Read(Header, sizeof(*Header)) != sizeof(*Header)) + { + LOGERROR("ERROR READING %s FROM FILE %s (line %d); file offset %d", "Header", m_FileName.c_str(), __LINE__, f.Tell()); + delete Header; + return; + } m_ChunkHeaders.push_back(Header); } // for i - chunk headers |