aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Zwinkau <qznc@go.to>2012-07-03 23:13:15 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-07-21 22:09:17 +0300
commit28e7443f9bcc1fac186394847c1b788e39daed5e (patch)
tree5d2f3267961d279d27ef031c341bfdebe6acf988 /src
parente79ad21aebfe1dc4227ae1f8dd3a2f1c0b5ba193 (diff)
downloadminetest-28e7443f9bcc1fac186394847c1b788e39daed5e.tar.gz
minetest-28e7443f9bcc1fac186394847c1b788e39daed5e.tar.bz2
minetest-28e7443f9bcc1fac186394847c1b788e39daed5e.zip
Fix wctomb use
wctomb(NULL, _) returns "nonzero if the encoding has nontrivial shift state, or zero if the encoding is stateless." I assume the intentation was to get the size of the target buffer. Use MB_CUR_MAX for this.
Diffstat (limited to 'src')
-rw-r--r--src/keycode.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/keycode.cpp b/src/keycode.cpp
index c3c06bb7f..df3ebc9e3 100644
--- a/src/keycode.cpp
+++ b/src/keycode.cpp
@@ -293,8 +293,7 @@ KeyPress::KeyPress(const irr::SEvent::SKeyInput &in)
if (valid_kcode(Key)) {
m_name = KeyNames[Key];
} else {
- size_t maxlen = wctomb(NULL, Char);
- m_name.resize(maxlen+1, '\0');
+ m_name.resize(MB_CUR_MAX+1, '\0');
int written = wctomb(&m_name[0], Char);
assert (written >= 0 && "unexpected multibyte character");
}