summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertram <yohanndotferreiraatorange.fr>2010-03-08 23:23:42 +0100
committerBertram <yohanndotferreiraatorange.fr>2010-03-08 23:23:42 +0100
commit30668a131bb2c93127385fbbbba34d47f7bf80e3 (patch)
tree527944007818a853251f1b17ea1417b30a24236d
parent1037731516cad66027816d416b188bb9aa097b60 (diff)
downloadmana-client-30668a131bb2c93127385fbbbba34d47f7bf80e3.tar.gz
mana-client-30668a131bb2c93127385fbbbba34d47f7bf80e3.tar.bz2
mana-client-30668a131bb2c93127385fbbbba34d47f7bf80e3.tar.xz
mana-client-30668a131bb2c93127385fbbbba34d47f7bf80e3.zip
Fix crash with incorrect wallpaper names. (From 4144)
Reviewed-by: Bertram
-rw-r--r--src/resources/wallpaper.cpp27
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);
+ }
}
}