diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index b08fd0b7ab7..a863336c253 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -822,28 +822,28 @@ static HRESULT WINAPI mxwriter_saxcontent_endElement( int nQName) { mxwriter *This = impl_from_ISAXContentHandler( iface ); - xmlChar *s; - TRACE("(%p)->(%s %s %s)\n", This, debugstr_wn(namespaceUri, nnamespaceUri), - debugstr_wn(local_name, nlocal_name), debugstr_wn(QName, nQName)); + TRACE("(%p)->(%s:%d %s:%d %s:%d)\n", This, debugstr_wn(namespaceUri, nnamespaceUri), nnamespaceUri, + debugstr_wn(local_name, nlocal_name), nlocal_name, debugstr_wn(QName, nQName), nQName); if ((!namespaceUri || !local_name || !QName) && This->class_version != MSXML6) return E_INVALIDARG; - s = xmlchar_from_wchar(QName); - - if (This->element && QName && !strcmpW(This->element, QName)) + if (This->element && QName && !strncmpW(This->element, QName, nQName)) { xmlOutputBufferWriteString(This->buffer, "/>"); } else { + xmlChar *s = xmlchar_from_wcharn(QName, nQName); + xmlOutputBufferWriteString(This->buffer, "buffer, (char*)s); xmlOutputBufferWriteString(This->buffer, ">"); + + heap_free(s); } - heap_free(s); set_element_name(This, NULL, 0); return S_OK; diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index 6493776d693..c52e03b5eea 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -2069,9 +2069,20 @@ static void test_mxwriter_startendelement(void) ok(!lstrcmpW(_bstr_(""), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); VariantClear(&dest); + ISAXContentHandler_endDocument(content); + IMXWriter_flush(writer); + + hr = ISAXContentHandler_endElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("abdcdef"), 3); + EXPECT_HR(hr, S_OK); + V_VT(&dest) = VT_EMPTY; + hr = IMXWriter_get_output(writer, &dest); + EXPECT_HR(hr, S_OK); + ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); + ok(!lstrcmpW(_bstr_(""), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); + VariantClear(&dest); + ISAXContentHandler_Release(content); IMXWriter_Release(writer); - free_bstrs(); }