summaryrefslogtreecommitdiff
path: root/src/screenshot.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-11-01 17:49:23 +0000
committersmatz <smatz@openttd.org>2009-11-01 17:49:23 +0000
commitb577595d1289dec5eacb671adbd5592eab39c5eb (patch)
treecfa074d41193e795ed7e8e29c0df00bbd7fc45e6 /src/screenshot.cpp
parent2211e3faad2d6fda5e13fbacc5487d2298feb5d8 (diff)
downloadopenttd-b577595d1289dec5eacb671adbd5592eab39c5eb.tar.xz
(svn r17936) -Fix: deadlock when trying to create screenshot with too long name (including path)
Diffstat (limited to 'src/screenshot.cpp')
-rw-r--r--src/screenshot.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 200151b70..1515186e8 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -554,7 +554,11 @@ static char *MakeScreenshotName(const char *ext)
snprintf(&_screenshot_name[len], lengthof(_screenshot_name) - len, ".%s", ext);
for (serial = 1;; serial++) {
- snprintf(filename, lengthof(filename), "%s%s", _personal_dir, _screenshot_name);
+ if (snprintf(filename, lengthof(filename), "%s%s", _personal_dir, _screenshot_name) >= (int)lengthof(filename)) {
+ /* We need more characters than MAX_PATH -> end with error */
+ filename[0] = '\0';
+ break;
+ }
if (!FileExists(filename)) break;
/* If file exists try another one with same name, but just with a higher index */
snprintf(&_screenshot_name[len], lengthof(_screenshot_name) - len, "#%d.%s", serial, ext);