From 291ffdd7fff9a65d231c1ad76648bb6da6da26f9 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 28 Mar 2017 17:27:17 +0200 Subject: [PATCH] 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 Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/xmllite/reader.c | 2 +- dlls/xmllite/tests/reader.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index de24537c844..e81f266a68e 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -875,7 +875,7 @@ static HRESULT readerinput_detectencoding(xmlreaderinput *readerinput, xml_encod { HRESULT hr = readerinput_growraw(readerinput); 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; diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c index c34230337ce..40873a403ac 100644 --- a/dlls/xmllite/tests/reader.c +++ b/dlls/xmllite/tests/reader.c @@ -1447,7 +1447,6 @@ static void test_read_element(void) static const UINT depths[] = { 0, 1, 2, 2, 2, 3, 2, 1 }; IXmlReader *reader; XmlNodeType type; - IStream *stream; unsigned int i; UINT depth; HRESULT hr; @@ -1457,9 +1456,7 @@ static void test_read_element(void) while (test->xml) { - stream = create_stream_on_data(test->xml, strlen(test->xml)+1); - hr = IXmlReader_SetInput(reader, (IUnknown*)stream); - ok(hr == S_OK, "got %08x\n", hr); + set_input_string(reader, test->xml); type = XmlNodeType_None; 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)); } - IStream_Release(stream); test++; }