From 3b9da089e540503101efbf0115e8369c33f47fd6 Mon Sep 17 00:00:00 2001 From: yexo Date: Mon, 22 Feb 2010 20:18:59 +0000 Subject: (svn r19212) -Fix: base graphics set with an empty filename in the obg file caused segfaults --- src/base_media_base.h | 3 ++- src/base_media_func.h | 4 ++-- src/gfxinit.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/base_media_base.h b/src/base_media_base.h index 5ff85f268..4b43c24fd 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -108,9 +108,10 @@ struct BaseSet { * Read the set information from a loaded ini. * @param ini the ini to read from * @param path the path to this ini file (for filenames) + * @param allow_empty_filename empty filenames are valid * @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. diff --git a/src/base_media_func.h b/src/base_media_func.h index ba0f75acd..aa339452c 100644 --- a/src/base_media_func.h +++ b/src/base_media_func.h @@ -30,7 +30,7 @@ template /* static */ Tbase_set *BaseMedia::availab } template -bool BaseSet::FillSetDetails(IniFile *ini, const char *path) +bool BaseSet::FillSetDetails(IniFile *ini, const char *path, bool allow_empty_filename) { memset(this, 0, sizeof(*this)); @@ -69,7 +69,7 @@ bool BaseSet::FillSetDetails(IniFile *ini, const char *p MD5File *file = &this->files[i]; /* Find the filename first. */ item = files->GetItem(BaseSet::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::file_names[i]); return false; } diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 188b6c87b..f2678ae09 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -205,7 +205,7 @@ void GfxLoadSprites() bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path) { - bool ret = this->BaseSet::FillSetDetails(ini, path); + bool ret = this->BaseSet::FillSetDetails(ini, path, false); if (ret) { IniGroup *metadata = ini->GetGroup("metadata"); IniItem *item; -- cgit v1.2.3-70-g09d2