From: Côme Chilliet Date: Sat, 10 Dec 2016 05:59:17 +0000 (+0700) Subject: Fix a crash when map contains a negative number of hotspots X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=3e35667d102382398aa701a883f1fd951eed0ee3;p=lugaru.git Fix a crash when map contains a negative number of hotspots --- diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index a8a5cfb..efd06e7 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -992,6 +992,10 @@ void Game::Loadlevel(const std::string& name) if (mapvers >= 7) { int numhotspots; funpackf(tfile, "Bi", &numhotspots); + if (numhotspots < 0) { + cerr << "Map " << name << " have an invalid number of hotspots" << endl; + numhotspots = 0; + } Hotspot::hotspots.resize(numhotspots); for (int i = 0; i < Hotspot::hotspots.size(); i++) { funpackf(tfile, "Bi Bf Bf Bf Bf", &Hotspot::hotspots[i].type, &Hotspot::hotspots[i].size, &Hotspot::hotspots[i].position.x, &Hotspot::hotspots[i].position.y, &Hotspot::hotspots[i].position.z); diff --git a/Source/main.cpp b/Source/main.cpp index 4ff4ebc..e0bf430 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -626,7 +626,7 @@ int main(int argc, char **argv) LOGFUNC; - try { + //~ try { { newGame(); @@ -677,16 +677,16 @@ int main(int argc, char **argv) CleanUp (); return 0; - } catch (const std::exception& error) { - CleanUp(); + //~ } catch (const std::exception& error) { + //~ CleanUp(); - std::string e = "Caught exception: "; - e += error.what(); + //~ std::string e = "Caught exception: "; + //~ e += error.what(); - LOG(e); + //~ LOG(e); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Exception catched", error.what(), NULL); + //~ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Exception catched", error.what(), NULL); - return -1; - } + //~ return -1; + //~ } }