xmllite: Don't fail in readerinput_detectencoding if input buffer has 3 bytes.

3 bytes are enough for detection code and we already have tests for
that, except they (accidentally, I assume) include null byte in the stream.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-03-28 17:27:17 +02:00 committed by Alexandre Julliard
parent bbd0ee4391
commit 291ffdd7ff
2 changed files with 2 additions and 6 deletions

View File

@ -875,7 +875,7 @@ static HRESULT readerinput_detectencoding(xmlreaderinput *readerinput, xml_encod
{ {
HRESULT hr = readerinput_growraw(readerinput); HRESULT hr = readerinput_growraw(readerinput);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
if (buffer->written <= 3) return MX_E_INPUTEND; if (buffer->written < 3) return MX_E_INPUTEND;
} }
ptrW = (WCHAR *)buffer->data; ptrW = (WCHAR *)buffer->data;

View File

@ -1447,7 +1447,6 @@ static void test_read_element(void)
static const UINT depths[] = { 0, 1, 2, 2, 2, 3, 2, 1 }; static const UINT depths[] = { 0, 1, 2, 2, 2, 3, 2, 1 };
IXmlReader *reader; IXmlReader *reader;
XmlNodeType type; XmlNodeType type;
IStream *stream;
unsigned int i; unsigned int i;
UINT depth; UINT depth;
HRESULT hr; HRESULT hr;
@ -1457,9 +1456,7 @@ static void test_read_element(void)
while (test->xml) while (test->xml)
{ {
stream = create_stream_on_data(test->xml, strlen(test->xml)+1); set_input_string(reader, test->xml);
hr = IXmlReader_SetInput(reader, (IUnknown*)stream);
ok(hr == S_OK, "got %08x\n", hr);
type = XmlNodeType_None; type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type); hr = IXmlReader_Read(reader, &type);
@ -1494,7 +1491,6 @@ static void test_read_element(void)
ok(*str == 0, "got %s\n", wine_dbgstr_w(str)); ok(*str == 0, "got %s\n", wine_dbgstr_w(str));
} }
IStream_Release(stream);
test++; test++;
} }