libport: Fix null character handling when mapping DBCS characters.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2016-05-15 21:08:47 +09:00 committed by Alexandre Julliard
parent cfe015a98c
commit 6938fec4ae
2 changed files with 8 additions and 8 deletions

View File

@ -1211,9 +1211,9 @@ static void test_dbcs_to_widechar(void)
{ {
WCHAR wbuf_ok[] = { 0x770b, 0x003f, '\0', 0xffff }; WCHAR wbuf_ok[] = { 0x770b, 0x003f, '\0', 0xffff };
WCHAR wbuf_broken[] = { 0x770b, '\0', 0xffff, 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); "%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))), || broken(!memcmp(wbuf, wbuf_broken, sizeof(wbuf_broken))),
"%04x: returned %04x %04x %04x %04x (expected %04x %04x %04x %04x)\n", "%04x: returned %04x %04x %04x %04x (expected %04x %04x %04x %04x)\n",
flags[i], wbuf[0], wbuf[1], wbuf[2], wbuf[3], 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_ok[] = { 0x770b, 0x003f, '\0', 'x', 0xffff };
WCHAR wbuf_broken[] = { 0x770b, '\0', 'x', 0xffff, 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); "%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))), || broken(!memcmp(wbuf, wbuf_broken, sizeof(wbuf_broken))),
"%04x: returned %04x %04x %04x %04x %04x (expected %04x %04x %04x %04x %04x)\n", "%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], flags[i], wbuf[0], wbuf[1], wbuf[2], wbuf[3], wbuf[4],

View File

@ -131,7 +131,7 @@ static inline int get_length_dbcs( const struct dbcs_table *table,
for (len = 0; srclen; srclen--, src++, len++) for (len = 0; srclen; srclen--, src++, len++)
{ {
if (cp2uni_lb[*src] && srclen > 1) if (cp2uni_lb[*src] && srclen > 1 && src[1])
{ {
src++; src++;
srclen--; srclen--;
@ -183,7 +183,7 @@ static inline int mbstowcs_dbcs( const struct dbcs_table *table,
for (len = dstlen; srclen && len; len--, srclen--, src++, dst++) for (len = dstlen; srclen && len; len--, srclen--, src++, dst++)
{ {
unsigned char off = cp2uni_lb[*src]; unsigned char off = cp2uni_lb[*src];
if (off && srclen > 1) if (off && srclen > 1 && src[1])
{ {
src++; src++;
srclen--; srclen--;
@ -212,7 +212,7 @@ static int mbstowcs_dbcs_decompose( const struct dbcs_table *table,
for (len = 0; srclen; srclen--, src++) for (len = 0; srclen; srclen--, src++)
{ {
unsigned char off = cp2uni_lb[*src]; unsigned char off = cp2uni_lb[*src];
if (off && srclen > 1) if (off && srclen > 1 && src[1])
{ {
src++; src++;
srclen--; srclen--;
@ -227,7 +227,7 @@ static int mbstowcs_dbcs_decompose( const struct dbcs_table *table,
for (len = dstlen; srclen && len; srclen--, src++) for (len = dstlen; srclen && len; srclen--, src++)
{ {
unsigned char off = cp2uni_lb[*src]; unsigned char off = cp2uni_lb[*src];
if (off && srclen > 1) if (off && srclen > 1 && src[1])
{ {
src++; src++;
srclen--; srclen--;