Hans Leidekker : webservices: Fix calculation of the end of a UTF-8 sequence.

Alexandre Julliard julliard at winehq.org
Thu Nov 17 17:45:58 CST 2016


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Nov 17 10:10:56 2016 -0600

webservices: Fix calculation of the end of a UTF-8 sequence.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/webservices/reader.c       |  2 +-
 dlls/webservices/tests/reader.c | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index 5b5dc69..d67c47a 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -1035,7 +1035,7 @@ static inline unsigned int read_utf8_char( struct reader *reader, unsigned int *
     }
     len = utf8_length[ch - 0x80];
     if (reader->read_pos + len >= reader->read_size) return 0;
-    end = reader->read_bufptr + reader->read_pos + len;
+    end = reader->read_bufptr + reader->read_pos + len + 1;
     res = ch & utf8_mask[len];
 
     switch (len)
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index 23c3f10..b19bc8c 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -1325,6 +1325,8 @@ static void test_WsReadType(void)
     static const WCHAR testW[] = {'t','e','s','t',0};
     static const GUID guid1 = {0,0,0,{0,0,0,0,0,0,0,0}};
     static const GUID guid2 = {0,0,0,{0,0,0,0,0,0,0,0xa1}};
+    static const char utf8[] = {'<','t','>',0xe2,0x80,0x99,'<','/','t','>'};
+    static const WCHAR utf8W[] = {0x2019,0};
     HRESULT hr;
     WS_XML_READER *reader;
     WS_HEAP *heap;
@@ -1636,6 +1638,14 @@ static void test_WsReadType(void)
                      WS_READ_REQUIRED_VALUE, heap, &val_bytes, sizeof(val_bytes), NULL );
     ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
 
+    val_str = NULL;
+    prepare_type_test( reader, utf8, sizeof(utf8) );
+    hr = WsReadType( reader, WS_ELEMENT_CONTENT_TYPE_MAPPING, WS_WSZ_TYPE, NULL,
+                     WS_READ_REQUIRED_POINTER, heap, &val_str, sizeof(val_str), NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( val_str != NULL, "pointer not set\n" );
+    if (val_str) ok( !lstrcmpW( val_str, utf8W ), "wrong data %s\n", wine_dbgstr_w(val_str) );
+
     WsFreeReader( reader );
     WsFreeHeap( heap );
 }




More information about the wine-cvs mailing list