Author: iratqq
Date: Mon Jan 28 10:04:46 2008
New Revision: 5141
Modified:
trunk/xim/compose.cpp
Log:
* xim/compose.cpp (mb_string_to_utf8):
Fix off-by-one and unterminated string.
Modified: trunk/xim/compose.cpp
==============================================================================
--- trunk/xim/compose.cpp (original)
+++ trunk/xim/compose.cpp Mon Jan 28 10:04:46 2008
@@ -1215,7 +1215,7 @@
if (!cd)
return strlcpy(utf8, inbuf, len + 1);
- outbuf = (char *)malloc(outbufsize);
+ outbuf = (char *)malloc(outbufsize + 1);
if (!outbuf) {
uim_iconv->release(cd);
utf8[0] = '\0';
@@ -1235,6 +1235,8 @@
return 0;
}
uim_iconv->release(cd);
+
+ *outchar = '\0';
strlcpy(utf8, outbuf, outbufsize - outbytesleft + 1);
free(outbuf);