Changeset - r14514:69262db8f571
[Not reviewed]
master
0 2 0
yexo - 15 years ago 2010-02-11 15:08:55
yexo@openttd.org
(svn r19095) -Fix: segfault when a baseset has an empty metadata field
2 files changed with 2 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/base_media_func.h
Show inline comments
 
@@ -21,13 +21,13 @@ template <class Tbase_set> /* static */ 
 
/**
 
 * Try to read a single piece of metadata and return false if it doesn't exist.
 
 * @param name the name of the item to fetch.
 
 */
 
#define fetch_metadata(name) \
 
	item = metadata->GetItem(name, false); \
 
	if (item == NULL || strlen(item->value) == 0) { \
 
	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)
src/music.cpp
Show inline comments
 
@@ -53,23 +53,12 @@ template <class Tbase_set>
 
	}
 

	
 
	BaseMedia<Tbase_set>::used_set = best;
 
	return BaseMedia<Tbase_set>::used_set != NULL;
 
}
 

	
 
/**
 
 * Try to read a single piece of metadata and return false if it doesn't exist.
 
 * @param name the name of the item to fetch.
 
 */
 
#define fetch_name(name) \
 
	item = metadata->GetItem(name, false); \
 
	if (item == NULL || strlen(item->value) == 0) { \
 
		DEBUG(grf, 0, "Base " SET_TYPE "set detail loading: %s field missing", name); \
 
		return false; \
 
	}
 

	
 
bool MusicSet::FillSetDetails(IniFile *ini, const char *path)
 
{
 
	bool ret = this->BaseSet<MusicSet, NUM_SONGS_AVAILABLE, GM_DIR>::FillSetDetails(ini, path);
 
	if (ret) {
 
		this->num_available = 0;
 
		IniGroup *names = ini->GetGroup("names");
 
@@ -78,13 +67,13 @@ bool MusicSet::FillSetDetails(IniFile *i
 
			if (names == NULL || StrEmpty(filename)) {
 
				this->song_name[i][0] = '\0';
 
				continue;
 
			}
 

	
 
			IniItem *item = names->GetItem(filename, false);
 
			if (item == NULL || strlen(item->value) == 0) {
 
			if (item == NULL || StrEmpty(item->value)) {
 
				DEBUG(grf, 0, "Base music set song name missing: %s", filename);
 
				return false;
 
			}
 

	
 
			strecpy(this->song_name[i], item->value, lastof(this->song_name[i]));
 
			this->track_nr[i] = j++;
0 comments (0 inline, 0 general)