From: Ricardo Cruz Date: Fri, 9 Jul 2004 22:16:50 +0000 (+0000) Subject: Fixed crash when LANG system's variable is not defined. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6c0f237a54594e0c6014ee5f4559a3f00adf33f3;p=supertux.git Fixed crash when LANG system's variable is not defined. SVN-Revision: 1559 --- diff --git a/src/lispreader.cpp b/src/lispreader.cpp index 2c49aad51..839ceeff6 100644 --- a/src/lispreader.cpp +++ b/src/lispreader.cpp @@ -1218,19 +1218,26 @@ LispReader::read_string (const char* name, std::string& str, bool translatable) (text-fr "Bonjour Monde!") being fr the value of LANG (echo $LANG) for the language we want to translate to */ + char* lang = getenv("LANG"); + char str_[1024]; // check, for instance, for (title-fr_FR "Bonjour") - sprintf(str_, "%s-%s", name, getenv("LANG")); + sprintf(str_, "%s-%s", name, lang); obj = search_for (str_); if(!obj) // check, for instance, for (title-fr "Bonjour") { - char lang[3]; - strncpy(lang, getenv("LANG"), 2); - lang[2] = '\0'; - sprintf(str_, "%s-%s", name, lang); + if(strlen(lang) >= 2) + { + char lang_[3]; + strncpy(lang_, lang, 2); + lang_[2] = '\0'; + sprintf(str_, "%s-%s", name, lang_); - obj = search_for (str_); + obj = search_for (str_); + } + else + obj = 0; } if(!obj) // check, for instance, for (title "Hello") diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 546db1edd..2f56ab3c3 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -361,7 +361,7 @@ WorldMap::WorldMap() input_direction = D_NONE; enter_level = false; - name = ""; + name = ""; music = "SALCON.MOD"; }