xmllite/reader: Enter error state on parsing error.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a44a608378
commit
ec9e05c27c
|
@ -264,6 +264,7 @@ typedef struct
|
|||
xmlreaderinput *input;
|
||||
IMalloc *imalloc;
|
||||
XmlReadState state;
|
||||
HRESULT error; /* error set on XmlReadState_Error */
|
||||
XmlReaderInternalState instate;
|
||||
XmlReaderResumeState resumestate;
|
||||
XmlNodeType nodetype;
|
||||
|
@ -2821,19 +2822,37 @@ static HRESULT WINAPI xmlreader_Read(IXmlReader* iface, XmlNodeType *nodetype)
|
|||
{
|
||||
xmlreader *This = impl_from_IXmlReader(iface);
|
||||
XmlNodeType oldtype = This->nodetype;
|
||||
XmlNodeType type;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, nodetype);
|
||||
|
||||
if (This->state == XmlReadState_Closed) return S_FALSE;
|
||||
if (!nodetype)
|
||||
nodetype = &type;
|
||||
|
||||
hr = reader_parse_nextnode(This);
|
||||
if (oldtype == XmlNodeType_None && This->nodetype != oldtype)
|
||||
This->state = XmlReadState_Interactive;
|
||||
switch (This->state)
|
||||
{
|
||||
case XmlReadState_Closed:
|
||||
hr = S_FALSE;
|
||||
break;
|
||||
case XmlReadState_Error:
|
||||
hr = This->error;
|
||||
break;
|
||||
default:
|
||||
hr = reader_parse_nextnode(This);
|
||||
if (SUCCEEDED(hr) && oldtype == XmlNodeType_None && This->nodetype != oldtype)
|
||||
This->state = XmlReadState_Interactive;
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
This->state = XmlReadState_Error;
|
||||
This->nodetype = XmlNodeType_None;
|
||||
This->error = hr;
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("node type %s\n", debugstr_nodetype(This->nodetype));
|
||||
if (nodetype)
|
||||
*nodetype = This->nodetype;
|
||||
*nodetype = This->nodetype;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -1559,8 +1559,8 @@ static void test_read_element(void)
|
|||
type = XmlNodeType_Element;
|
||||
hr = IXmlReader_Read(reader, &type);
|
||||
ok(hr == WC_E_ELEMENTMATCH, "got %08x\n", hr);
|
||||
todo_wine
|
||||
ok(type == XmlNodeType_None, "got %d\n", type);
|
||||
TEST_READER_STATE(reader, XmlReadState_Error);
|
||||
|
||||
IStream_Release(stream);
|
||||
|
||||
|
@ -2369,6 +2369,7 @@ static void test_max_element_depth(void)
|
|||
"</c>"
|
||||
"</b>"
|
||||
"</a>";
|
||||
XmlNodeType nodetype;
|
||||
unsigned int count;
|
||||
IXmlReader *reader;
|
||||
IStream *stream;
|
||||
|
@ -2401,20 +2402,19 @@ static void test_max_element_depth(void)
|
|||
hr = IXmlReader_Read(reader, NULL);
|
||||
ok(hr == SC_E_MAXELEMENTDEPTH, "got %08x\n", hr);
|
||||
|
||||
todo_wine {
|
||||
todo_wine
|
||||
TEST_DEPTH2(reader, 0, 2);
|
||||
TEST_READER_STATE(reader, XmlReadState_Error);
|
||||
}
|
||||
|
||||
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_MaxElementDepth, 10);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
|
||||
hr = IXmlReader_Read(reader, NULL);
|
||||
todo_wine {
|
||||
ok(hr == SC_E_MAXELEMENTDEPTH, "got %08x\n", hr);
|
||||
|
||||
todo_wine
|
||||
TEST_DEPTH2(reader, 0, 2);
|
||||
TEST_READER_STATE(reader, XmlReadState_Error);
|
||||
}
|
||||
IStream_Release(stream);
|
||||
|
||||
/* test if stepping into attributes enforces depth limit too */
|
||||
|
@ -2444,13 +2444,20 @@ todo_wine {
|
|||
TEST_DEPTH(reader, 2);
|
||||
TEST_READER_STATE(reader, XmlReadState_Interactive);
|
||||
|
||||
hr = IXmlReader_Read(reader, NULL);
|
||||
nodetype = 123;
|
||||
hr = IXmlReader_Read(reader, &nodetype);
|
||||
ok(hr == SC_E_MAXELEMENTDEPTH, "got %08x\n", hr);
|
||||
ok(nodetype == XmlNodeType_None, "got node type %d\n", nodetype);
|
||||
|
||||
todo_wine {
|
||||
nodetype = 123;
|
||||
hr = IXmlReader_Read(reader, &nodetype);
|
||||
ok(hr == SC_E_MAXELEMENTDEPTH, "got %08x\n", hr);
|
||||
ok(nodetype == XmlNodeType_None, "got node type %d\n", nodetype);
|
||||
|
||||
todo_wine
|
||||
TEST_DEPTH2(reader, 0, 2);
|
||||
TEST_READER_STATE(reader, XmlReadState_Error);
|
||||
}
|
||||
|
||||
IStream_Release(stream);
|
||||
|
||||
/* set max depth to 0, this disables depth limit */
|
||||
|
|
Loading…
Reference in New Issue