fix crash when filename is shorter than extension length
authorMatthias Braun <matze@braunis.de>
Sun, 18 May 2008 12:01:30 +0000 (12:01 +0000)
committerMatthias Braun <matze@braunis.de>
Sun, 18 May 2008 12:01:30 +0000 (12:01 +0000)
SVN-Revision: 5489

src/addon/addon_manager.cpp

index 4a783d8..68a50c5 100644 (file)
@@ -385,7 +385,11 @@ AddonManager::load_addons()
 
       // make sure it looks like an infoFile
       static const std::string infoExt = ".nfo";
-      if (potentialInfoFileName.compare(potentialInfoFileName.length()-infoExt.length(), infoExt.length(), infoExt) != 0) continue;
+      if (potentialInfoFileName.length() <= infoExt.length())
+         continue;
+
+      if (potentialInfoFileName.compare(potentialInfoFileName.length()-infoExt.length(), infoExt.length(), infoExt) != 0)
+         continue;
 
       // make sure it's in the current archive
       std::string infoFileDir = PHYSFS_getRealDir(potentialInfoFileName.c_str());