From e3a6d5932489d1988b0021b88f3c934b7af7e500 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 23 Mar 2016 13:07:29 +0300 Subject: [PATCH] xmllite/writer: Fix WriteEndElement()/WriteFullEndElement() on ready state. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/xmllite/tests/writer.c | 15 ++++++++++++++- dlls/xmllite/writer.c | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index a5d5b31a22b..ce4e13d5cbf 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -91,13 +91,14 @@ todo_wine hr = IXmlWriter_WriteEndElement(writer); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); -todo_wine { hr = IXmlWriter_WriteEntityRef(writer, aW); +todo_wine ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); hr = IXmlWriter_WriteFullEndElement(writer); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); +todo_wine { hr = IXmlWriter_WriteName(writer, aW); ok(hr == exp_hr, "got 0x%08x, expected 0x%08x\n", hr, exp_hr); @@ -915,13 +916,25 @@ static void test_WriteRaw(void) static void test_writer_state(void) { IXmlWriter *writer; + IStream *stream; HRESULT hr; hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + /* initial state */ check_writer_state(writer, E_UNEXPECTED); + /* set output and call 'wrong' method */ + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteEndElement(writer); + ok(hr == WR_E_INVALIDACTION, "got 0x%08x\n", hr); + + check_writer_state(writer, WR_E_INVALIDACTION); + + IStream_Release(stream); + IXmlWriter_Release(writer); } diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 0e55b42038e..6aa851fa1fc 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -788,6 +788,10 @@ static HRESULT WINAPI xmlwriter_WriteEndElement(IXmlWriter *iface) { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_Ready: + case XmlWriterState_DocClosed: + This->state = XmlWriterState_DocClosed; + return WR_E_INVALIDACTION; default: ; } @@ -827,6 +831,18 @@ static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface) TRACE("%p\n", This); + switch (This->state) + { + case XmlWriterState_Initial: + return E_UNEXPECTED; + case XmlWriterState_Ready: + case XmlWriterState_DocClosed: + This->state = XmlWriterState_DocClosed; + return WR_E_INVALIDACTION; + default: + ; + } + element = pop_element(This); if (!element) return WR_E_INVALIDACTION;