diff options
author | Bertram <yohanndotferreiraatorange.fr> | 2010-03-08 23:23:42 +0100 |
---|---|---|
committer | Bertram <yohanndotferreiraatorange.fr> | 2010-03-08 23:23:42 +0100 |
commit | 30668a131bb2c93127385fbbbba34d47f7bf80e3 (patch) | |
tree | 527944007818a853251f1b17ea1417b30a24236d /src/resources/wallpaper.cpp | |
parent | 1037731516cad66027816d416b188bb9aa097b60 (diff) | |
download | mana-30668a131bb2c93127385fbbbba34d47f7bf80e3.tar.gz mana-30668a131bb2c93127385fbbbba34d47f7bf80e3.tar.bz2 mana-30668a131bb2c93127385fbbbba34d47f7bf80e3.tar.xz mana-30668a131bb2c93127385fbbbba34d47f7bf80e3.zip |
Fix crash with incorrect wallpaper names. (From 4144)
Reviewed-by: Bertram
Diffstat (limited to 'src/resources/wallpaper.cpp')
-rw-r--r-- | src/resources/wallpaper.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 1f423508..f57f429d 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -73,20 +73,25 @@ void Wallpaper::loadWallpapers() // First, get the base filename of the image: std::string filename = *i; - int separator = filename.rfind("_"); + unsigned int separator = filename.rfind("_"); filename = filename.substr(0, separator); - // Then, append the width and height search mask. - filename.append("_%dx%d.png"); - - if (sscanf(*i, filename.c_str(), &width, &height) == 2) + // Check that the base filename doesn't have any '%' markers. + separator = filename.find("%"); + if (separator == std::string::npos) { - WallpaperData wp; - wp.filename = WALLPAPER_FOLDER; - wp.filename.append(*i); - wp.width = width; - wp.height = height; - wallpaperData.push_back(wp); + // Then, append the width and height search mask. + filename.append("_%dx%d.png"); + + if (sscanf(*i, filename.c_str(), &width, &height) == 2) + { + WallpaperData wp; + wp.filename = WALLPAPER_FOLDER; + wp.filename.append(*i); + wp.width = width; + wp.height = height; + wallpaperData.push_back(wp); + } } } |