1
0
Fork 0

(svn r19212) -Fix: base graphics set with an empty filename in the obg file caused segfaults

release/1.1
yexo 2010-02-22 20:18:59 +00:00
parent 1810351813
commit 3b9da089e5
3 changed files with 5 additions and 4 deletions

View File

@ -108,9 +108,10 @@ struct BaseSet {
* Read the set information from a loaded ini. * Read the set information from a loaded ini.
* @param ini the ini to read from * @param ini the ini to read from
* @param path the path to this ini file (for filenames) * @param path the path to this ini file (for filenames)
* @param allow_empty_filename empty filenames are valid
* @return true if loading was successful. * @return true if loading was successful.
*/ */
bool FillSetDetails(IniFile *ini, const char *path); bool FillSetDetails(IniFile *ini, const char *path, bool allow_empty_filename = true);
/** /**
* Get the description for the given ISO code. * Get the description for the given ISO code.

View File

@ -30,7 +30,7 @@ template <class Tbase_set> /* static */ Tbase_set *BaseMedia<Tbase_set>::availab
} }
template <class T, size_t Tnum_files, Subdirectory Tsubdir> template <class T, size_t Tnum_files, Subdirectory Tsubdir>
bool BaseSet<T, Tnum_files, Tsubdir>::FillSetDetails(IniFile *ini, const char *path) bool BaseSet<T, Tnum_files, Tsubdir>::FillSetDetails(IniFile *ini, const char *path, bool allow_empty_filename)
{ {
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
@ -69,7 +69,7 @@ bool BaseSet<T, Tnum_files, Tsubdir>::FillSetDetails(IniFile *ini, const char *p
MD5File *file = &this->files[i]; MD5File *file = &this->files[i];
/* Find the filename first. */ /* Find the filename first. */
item = files->GetItem(BaseSet<T, Tnum_files, Tsubdir>::file_names[i], false); item = files->GetItem(BaseSet<T, Tnum_files, Tsubdir>::file_names[i], false);
if (item == NULL) { if (item == NULL || (item->value == NULL && !allow_empty_filename)) {
DEBUG(grf, 0, "No " SET_TYPE " file for: %s", BaseSet<T, Tnum_files, Tsubdir>::file_names[i]); DEBUG(grf, 0, "No " SET_TYPE " file for: %s", BaseSet<T, Tnum_files, Tsubdir>::file_names[i]);
return false; return false;
} }

View File

@ -205,7 +205,7 @@ void GfxLoadSprites()
bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path) bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path)
{ {
bool ret = this->BaseSet<GraphicsSet, MAX_GFT, DATA_DIR>::FillSetDetails(ini, path); bool ret = this->BaseSet<GraphicsSet, MAX_GFT, DATA_DIR>::FillSetDetails(ini, path, false);
if (ret) { if (ret) {
IniGroup *metadata = ini->GetGroup("metadata"); IniGroup *metadata = ini->GetGroup("metadata");
IniItem *item; IniItem *item;