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

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-11-17 10:10:56 -06:00 committed by Alexandre Julliard
parent 28f66b2a34
commit 43e213e24c
2 changed files with 11 additions and 1 deletions

View File

@ -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)

View File

@ -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 );
}