]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Fix a crash when map contains a negative number of hotspots
[lugaru.git] / Source / GameTick.cpp
index a8a5cfb67bf8e4ce50da4ba00c8c4b82ff5f25cf..efd06e752eb7fb921b95e493ebd81da29f5b5149 100644 (file)
@@ -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);