Akihiro Sagawa : libport: Fix null character handling when mapping DBCS characters.

Alexandre Julliard julliard at wine.codeweavers.com
Tue May 17 11:19:38 CDT 2016


Module: wine
Branch: master
Commit: 6938fec4aeb3b94ed184e3c272e7e278f354117e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6938fec4aeb3b94ed184e3c272e7e278f354117e

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Sun May 15 21:08:47 2016 +0900

libport: Fix null character handling when mapping DBCS characters.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/codepage.c | 8 ++++----
 libs/port/mbtowc.c             | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 3161b8b..8eccf99 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -1211,9 +1211,9 @@ static void test_dbcs_to_widechar(void)
         {
             WCHAR wbuf_ok[]     = { 0x770b, 0x003f, '\0', 0xffff };
             WCHAR wbuf_broken[] = { 0x770b, '\0', 0xffff, 0xffff };
-            todo_wine ok(count == 3 || broken(count == 2 /*windows xp*/),
+            ok(count == 3 || broken(count == 2 /*windows xp*/),
                "%04x: returned %d (expected 3)\n", flags[i], count);
-            todo_wine ok(!memcmp(wbuf, wbuf_ok, sizeof(wbuf_ok))
+            ok(!memcmp(wbuf, wbuf_ok, sizeof(wbuf_ok))
                || broken(!memcmp(wbuf, wbuf_broken, sizeof(wbuf_broken))),
                "%04x: returned %04x %04x %04x %04x (expected %04x %04x %04x %04x)\n",
                flags[i], wbuf[0], wbuf[1], wbuf[2], wbuf[3],
@@ -1240,9 +1240,9 @@ static void test_dbcs_to_widechar(void)
         {
             WCHAR wbuf_ok[]     = { 0x770b, 0x003f, '\0', 'x', 0xffff };
             WCHAR wbuf_broken[] = { 0x770b, '\0', 'x', 0xffff, 0xffff };
-            todo_wine ok(count == 4 || broken(count == 3),
+            ok(count == 4 || broken(count == 3),
                "%04x: returned %d (expected 4)\n", flags[i], count);
-            todo_wine ok(!memcmp(wbuf, wbuf_ok, sizeof(wbuf_ok))
+            ok(!memcmp(wbuf, wbuf_ok, sizeof(wbuf_ok))
                || broken(!memcmp(wbuf, wbuf_broken, sizeof(wbuf_broken))),
                "%04x: returned %04x %04x %04x %04x %04x (expected %04x %04x %04x %04x %04x)\n",
                flags[i], wbuf[0], wbuf[1], wbuf[2], wbuf[3], wbuf[4],
diff --git a/libs/port/mbtowc.c b/libs/port/mbtowc.c
index fd7764e..4977c82 100644
--- a/libs/port/mbtowc.c
+++ b/libs/port/mbtowc.c
@@ -131,7 +131,7 @@ static inline int get_length_dbcs( const struct dbcs_table *table,
 
     for (len = 0; srclen; srclen--, src++, len++)
     {
-        if (cp2uni_lb[*src] && srclen > 1)
+        if (cp2uni_lb[*src] && srclen > 1 && src[1])
         {
             src++;
             srclen--;
@@ -183,7 +183,7 @@ static inline int mbstowcs_dbcs( const struct dbcs_table *table,
     for (len = dstlen; srclen && len; len--, srclen--, src++, dst++)
     {
         unsigned char off = cp2uni_lb[*src];
-        if (off && srclen > 1)
+        if (off && srclen > 1 && src[1])
         {
             src++;
             srclen--;
@@ -212,7 +212,7 @@ static int mbstowcs_dbcs_decompose( const struct dbcs_table *table,
         for (len = 0; srclen; srclen--, src++)
         {
             unsigned char off = cp2uni_lb[*src];
-            if (off && srclen > 1)
+            if (off && srclen > 1 && src[1])
             {
                 src++;
                 srclen--;
@@ -227,7 +227,7 @@ static int mbstowcs_dbcs_decompose( const struct dbcs_table *table,
     for (len = dstlen; srclen && len; srclen--, src++)
     {
         unsigned char off = cp2uni_lb[*src];
-        if (off && srclen > 1)
+        if (off && srclen > 1 && src[1])
         {
             src++;
             srclen--;




More information about the wine-cvs mailing list