]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix wctomb use
authorAndreas Zwinkau <qznc@go.to>
Tue, 3 Jul 2012 21:13:15 +0000 (23:13 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 21 Jul 2012 19:09:17 +0000 (22:09 +0300)
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.

src/keycode.cpp

index c3c06bb7f7b96d5b14a6522483852392d482d5c0..df3ebc9e316cd273a7e96590a4747cbabba251c7 100644 (file)
@@ -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");
        }