Fix a possible NULL pointer dereference...

...when a saved game's campaign is not present (reported by UMC
Invasion from the Unknown)
This commit is contained in:
Ignacio R. Morelle 2008-04-01 12:03:22 +00:00
parent c6187b7c67
commit fd632a6b96

View file

@ -549,9 +549,15 @@ void save_preview_pane::draw_contents()
if(campaign_type == "scenario") {
const config* campaign = game_config_->find_child("campaign","id",summary["campaign"]);
utils::string_map symbols;
symbols["campaign_name"] = (*campaign)["name"];
str << vgettext("Campaign: $campaign_name", symbols); // FIXME: isn't this superfluous?
if (campaign != NULL) {
utils::string_map symbols;
symbols["campaign_name"] = (*campaign)["name"];
//!@todo FIXME: this is a superfluous manner of making the string, however, I'll keep it
//! for the sake of not messing with the human side of i18n
str << vgettext("Campaign: $campaign_name", symbols); // FIXME: isn't this superfluous?
} else {
str << _("#(unknown campaign)");
}
} else if(campaign_type == "multiplayer") {
str << _("Multiplayer");
} else if(campaign_type == "tutorial") {