Changeset - r14625:3de0713d85fd
[Not reviewed]
master
0 3 0
yexo - 15 years ago 2010-02-22 20:18:59
yexo@openttd.org
(svn r19212) -Fix: base graphics set with an empty filename in the obg file caused segfaults
3 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/base_media_base.h
Show inline comments
 
@@ -105,15 +105,16 @@ 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.
 
	 * It falls back to the first two characters of the ISO code in case
 
	 * no match could be made with the full ISO code. If even then the
 
	 * matching fails the default is returned.
src/base_media_func.h
Show inline comments
 
@@ -27,13 +27,13 @@ template <class Tbase_set> /* static */ 
 
	if (item == NULL || StrEmpty(item->value)) { \
 
		DEBUG(grf, 0, "Base " SET_TYPE "set detail loading: %s field missing", name); \
 
		return false; \
 
	}
 

	
 
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));
 

	
 
	IniGroup *metadata = ini->GetGroup("metadata");
 
	IniItem *item;
 

	
 
@@ -66,13 +66,13 @@ bool BaseSet<T, Tnum_files, Tsubdir>::Fi
 
	IniGroup *md5s   = ini->GetGroup("md5s");
 
	IniGroup *origin = ini->GetGroup("origin");
 
	for (uint i = 0; i < Tnum_files; i++) {
 
		MD5File *file = &this->files[i];
 
		/* Find the filename first. */
 
		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]);
 
			return false;
 
		}
 

	
 
		const char *filename = item->value;
 
		if (filename == NULL) {
src/gfxinit.cpp
Show inline comments
 
@@ -202,13 +202,13 @@ void GfxLoadSprites()
 
	LoadSpriteTables();
 
	GfxInitPalettes();
 
}
 

	
 
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) {
 
		IniGroup *metadata = ini->GetGroup("metadata");
 
		IniItem *item;
 

	
 
		fetch_metadata("palette");
 
		this->palette = (*item->value == 'D' || *item->value == 'd') ? PAL_DOS : PAL_WINDOWS;
0 comments (0 inline, 0 general)