glib r7578 - in trunk: . glib



Author: tml
Date: Wed Oct  8 20:35:39 2008
New Revision: 7578
URL: http://svn.gnome.org/viewvc/glib?rev=7578&view=rev

Log:
2008-10-08  Tor Lillqvist  <tml novell com>

	Bug 554790 - g_convert() misbehaves with winiconv versions

	* glib/win_iconv.c (kernel_mbtowc): If converting from ASCII,
	explicitly check for and reject 8bit chars. MultiByteToWideChar()
	doesn't, at least not on XP.



Modified:
   trunk/ChangeLog
   trunk/glib/win_iconv.c

Modified: trunk/glib/win_iconv.c
==============================================================================
--- trunk/glib/win_iconv.c	(original)
+++ trunk/glib/win_iconv.c	Wed Oct  8 20:35:39 2008
@@ -1362,6 +1362,12 @@
     len = cv->mblen(cv, buf, bufsize);
     if (len == -1)
         return -1;
+    /* If converting from ASCII, reject 8bit
+     * chars. MultiByteToWideChar() doesn't. Note that for ASCII we
+     * know that the mblen function is sbcs_mblen() so len is 1.
+     */
+    if (cv->codepage == 20127 && buf[0] >= 0x80)
+        return_error(EILSEQ);
     *wbufsize = MultiByteToWideChar(cv->codepage, mbtowc_flags (cv->codepage),
             (const char *)buf, len, (wchar_t *)wbuf, *wbufsize);
     if (*wbufsize == 0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]