Skip to content

Commit 829bbaf

Browse files
committedSep 10, 2017
Fix incorrect buffer size calculation on creation of HUD status messages
Fixes #6400
1 parent 51002b1 commit 829bbaf

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

Diff for: ‎src/game.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ void Game::processKeyInput()
25672567
wchar_t buf[100];
25682568
g_settings->setFloat("sound_volume", new_volume);
25692569
const wchar_t *str = wgettext("Volume changed to %d%%");
2570-
swprintf(buf, sizeof(buf), str, myround(new_volume * 100));
2570+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
25712571
delete[] str;
25722572
m_statustext = buf;
25732573
runData.statustext_time = 0;
@@ -2576,7 +2576,7 @@ void Game::processKeyInput()
25762576
wchar_t buf[100];
25772577
g_settings->setFloat("sound_volume", new_volume);
25782578
const wchar_t *str = wgettext("Volume changed to %d%%");
2579-
swprintf(buf, sizeof(buf), str, myround(new_volume * 100));
2579+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
25802580
delete[] str;
25812581
m_statustext = buf;
25822582
runData.statustext_time = 0;
@@ -2968,7 +2968,7 @@ void Game::toggleProfiler()
29682968
if (runData.profiler_current_page != 0) {
29692969
wchar_t buf[255];
29702970
const wchar_t* str = wgettext("Profiler shown (page %d of %d)");
2971-
swprintf(buf, sizeof(buf), str,
2971+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str,
29722972
runData.profiler_current_page,
29732973
runData.profiler_max_page);
29742974
delete[] str;
@@ -2990,13 +2990,13 @@ void Game::increaseViewRange()
29902990
if (range_new > 4000) {
29912991
range_new = 4000;
29922992
str = wgettext("Viewing range is at maximum: %d");
2993-
swprintf(buf, sizeof(buf), str, range_new);
2993+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
29942994
delete[] str;
29952995
m_statustext = buf;
29962996

29972997
} else {
29982998
str = wgettext("Viewing range changed to %d");
2999-
swprintf(buf, sizeof(buf), str, range_new);
2999+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
30003000
delete[] str;
30013001
m_statustext = buf;
30023002
}
@@ -3015,12 +3015,12 @@ void Game::decreaseViewRange()
30153015
if (range_new < 20) {
30163016
range_new = 20;
30173017
str = wgettext("Viewing range is at minimum: %d");
3018-
swprintf(buf, sizeof(buf), str, range_new);
3018+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
30193019
delete[] str;
30203020
m_statustext = buf;
30213021
} else {
30223022
str = wgettext("Viewing range changed to %d");
3023-
swprintf(buf, sizeof(buf), str, range_new);
3023+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, range_new);
30243024
delete[] str;
30253025
m_statustext = buf;
30263026
}

0 commit comments

Comments
 (0)
Please sign in to comment.