summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2017-09-10 02:39:37 +0100
committerrubenwardy <rw@rubenwardy.com>2017-09-10 02:53:23 +0100
commit829bbafb271c8bbd268b959f6ef9b7b2a2fc8558 (patch)
treebc7338dffd039c7e42964584ba71a26331183534
parent51002b1629c69adb0053bc36d3667d2b790e5c21 (diff)
downloadminetest-829bbafb271c8bbd268b959f6ef9b7b2a2fc8558.tar.gz
minetest-829bbafb271c8bbd268b959f6ef9b7b2a2fc8558.tar.bz2
minetest-829bbafb271c8bbd268b959f6ef9b7b2a2fc8558.zip
Fix incorrect buffer size calculation on creation of HUD status messages
Fixes #6400
-rw-r--r--src/game.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/game.cpp b/src/game.cpp
index bb1875cf3..04688e476 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2567,7 +2567,7 @@ void Game::processKeyInput()
wchar_t buf[100];
g_settings->setFloat("sound_volume", new_volume);
const wchar_t *str = wgettext("Volume changed to %d%%");
- swprintf(buf, sizeof(buf), str, myround(new_volume * 100));
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
delete[] str;
m_statustext = buf;
runData.statustext_time = 0;
@@ -2576,7 +2576,7 @@ void Game::processKeyInput()
wchar_t buf[100];
g_settings->setFloat("sound_volume", new_volume);
const wchar_t *str = wgettext("Volume changed to %d%%");
- swprintf(buf, sizeof(buf), str, myround(new_volume * 100));
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
delete[] str;
m_statustext = buf;
runData.statustext_time = 0;
@@ -2968,7 +2968,7 @@ void Game::toggleProfiler()
if (runData.profiler_current_page != 0) {
wchar_t buf[255];
const wchar_t* str = wgettext("Profiler shown (page %d of %d)");
- swprintf(buf, sizeof(buf), str,
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str,
runData.profiler_current_page,
runData.profiler_max_page);
delete[] str;
@@ -2990,13 +2990,13 @@ void Game::increaseViewRange()
if (range_new > 4000) {
range_new = 4000;
str = wgettext("Viewing range is at maximum: %d");
- swprintf(buf, sizeof(buf), str, range_new);
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
delete[] str;
m_statustext = buf;
} else {
str = wgettext("Viewing range changed to %d");
- swprintf(buf, sizeof(buf), str, range_new);
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
delete[] str;
m_statustext = buf;
}
@@ -3015,12 +3015,12 @@ void Game::decreaseViewRange()
if (range_new < 20) {
range_new = 20;
str = wgettext("Viewing range is at minimum: %d");
- swprintf(buf, sizeof(buf), str, range_new);
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
delete[] str;
m_statustext = buf;
} else {
str = wgettext("Viewing range changed to %d");
- swprintf(buf, sizeof(buf), str, range_new);
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
delete[] str;
m_statustext = buf;
}