be sure not to call std::string::compare() with a negative offset as 1st arg

This commit is contained in:
Yann Dirson 2005-01-28 23:38:52 +00:00
parent 675df0d348
commit 2c4c51caf7
2 changed files with 5 additions and 3 deletions

View file

@ -11,6 +11,7 @@ CVS HEAD:
* fixed editor to work with zipios support enabled
* fixed zipios support to honor path to data given on command-line
* new cmd line option --fps to display frames/second refresh in game
* fixed zipios support crashes when running from CVS
* fixed bugs when replacing player with observer in mp
* fixed several pathfinding bugs
* code cleanups

View file

@ -85,7 +85,8 @@ namespace {
if ((**i).isValid()) {
const std::string fname = (**i).getName();
const std::string suffix = ".zip";
if (0 == fname.compare(fname.size() - suffix.size(), suffix.size(), suffix)) {
if ((fname.size() > suffix.size()) &&
(0 == fname.compare(fname.size() - suffix.size(), suffix.size(), suffix))) {
zipios::ZipFile zip(game_config::path + "/" + fname);
the_collection.addCollection(zip);
LOG_G << "zip collection " << fname <<
@ -103,14 +104,14 @@ bool filesystem_init()
{
#ifdef USE_ZIPIOS
if (!get_user_data_dir().empty()) {
LOG_G << "looking at dir " << get_user_data_dir() << "\n";
LOG_G << "looking at user dir " << get_user_data_dir() << "\n";
zipios::DirectoryCollection dir(get_user_data_dir());
LOG_G << "user collection has " << dir.size() << " elements\n";
the_collection.addCollection(dir);
register_zipdir(get_user_data_dir());
}
if (!game_config::path.empty()) {
LOG_G << "looking at dir " << game_config::path << "\n";
LOG_G << "looking at system dir " << game_config::path << "\n";
zipios::DirectoryCollection dir(game_config::path);
LOG_G << "system collection has " << dir.size() << " elements\n";
the_collection.addCollection(dir);