summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-02-11 15:08:55 +0000
committeryexo <yexo@openttd.org>2010-02-11 15:08:55 +0000
commitf70929022017d6f1cd8538cc2a26614e5fbd7e19 (patch)
treee01100a717ccfe818c439e4083c41a3b611459a4
parent6406b75b8fb1e1a15dde10534c1fe3aa235e9903 (diff)
downloadopenttd-f70929022017d6f1cd8538cc2a26614e5fbd7e19.tar.xz
(svn r19095) -Fix: segfault when a baseset has an empty metadata field
-rw-r--r--src/base_media_func.h2
-rw-r--r--src/music.cpp13
2 files changed, 2 insertions, 13 deletions
diff --git a/src/base_media_func.h b/src/base_media_func.h
index 434a6c722..bed6e57e9 100644
--- a/src/base_media_func.h
+++ b/src/base_media_func.h
@@ -24,7 +24,7 @@ template <class Tbase_set> /* static */ Tbase_set *BaseMedia<Tbase_set>::availab
*/
#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; \
}
diff --git a/src/music.cpp b/src/music.cpp
index b095a4197..e902f4b80 100644
--- a/src/music.cpp
+++ b/src/music.cpp
@@ -56,17 +56,6 @@ template <class Tbase_set>
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);
@@ -81,7 +70,7 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path)
}
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;
}