xmllite/reader: Fix IID argument handling in CreateXmlReader().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-04-11 14:28:40 +03:00 committed by Alexandre Julliard
parent d5d863597d
commit d1e14576bb
2 changed files with 22 additions and 11 deletions

View File

@ -3603,16 +3603,11 @@ static const struct IUnknownVtbl xmlreaderinputvtbl =
HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc) HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
{ {
xmlreader *reader; xmlreader *reader;
HRESULT hr;
int i; int i;
TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc); TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc);
if (!IsEqualGUID(riid, &IID_IXmlReader))
{
ERR("Unexpected IID requested -> (%s)\n", wine_dbgstr_guid(riid));
return E_FAIL;
}
if (imalloc) if (imalloc)
reader = IMalloc_Alloc(imalloc, sizeof(*reader)); reader = IMalloc_Alloc(imalloc, sizeof(*reader));
else else
@ -3640,11 +3635,12 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
for (i = 0; i < StringValue_Last; i++) for (i = 0; i < StringValue_Last; i++)
reader->strvalues[i] = strval_empty; reader->strvalues[i] = strval_empty;
*obj = &reader->IXmlReader_iface; hr = IXmlReader_QueryInterface(&reader->IXmlReader_iface, riid, obj);
IXmlReader_Release(&reader->IXmlReader_iface);
TRACE("returning iface %p\n", *obj); TRACE("returning iface %p, hr %#x\n", *obj, hr);
return S_OK; return hr;
} }
HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream,

View File

@ -536,11 +536,11 @@ static IXmlResolver testresolver = { &resolvervtbl };
static void test_reader_create(void) static void test_reader_create(void)
{ {
IXmlResolver *resolver; IXmlResolver *resolver;
HRESULT hr; IUnknown *input, *unk;
IXmlReader *reader; IXmlReader *reader;
IUnknown *input;
DtdProcessing dtd; DtdProcessing dtd;
XmlNodeType nodetype; XmlNodeType nodetype;
HRESULT hr;
/* crashes native */ /* crashes native */
if (0) if (0)
@ -549,6 +549,21 @@ static void test_reader_create(void)
CreateXmlReader(NULL, (void**)&reader, NULL); CreateXmlReader(NULL, (void**)&reader, NULL);
} }
hr = CreateXmlReader(&IID_IStream, (void **)&unk, NULL);
ok(hr == E_NOINTERFACE, "got %08x\n", hr);
hr = CreateXmlReader(&IID_IUnknown, (void **)&unk, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
hr = IUnknown_QueryInterface(unk, &IID_IXmlReader, (void **)&reader);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(unk == (IUnknown *)reader, "unexpected interface\n");
IXmlReader_Release(reader);
IUnknown_Release(unk);
hr = CreateXmlReader(&IID_IUnknown, (void **)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
IXmlReader_Release(reader);
hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL); hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);