The basic loop correctly finds the first element, however the second element repeats the first node, since it was incremented and the ns->next was skipped over.
-- v3: msxml3: Correct looping of Document Element node map.
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
The basic loop correctly finds the first element, however the second element repeats the first node, since it was incremented and the ns->next was skipped over. --- dlls/msxml3/element.c | 10 ++++++-- dlls/msxml3/tests/domdoc.c | 52 +++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index 394a4b28201..72d6f1b1223 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -1819,10 +1819,16 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode * if (!node->nsDef) return S_FALSE;
- attrIndex++; ns = node->nsDef; - for (; attrIndex < index && ns->next != NULL; attrIndex++) + while (attrIndex < index) + { + attrIndex++; + + if (!ns->next) + break; + ns = ns->next; + }
if (attrIndex < index) return S_FALSE; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 81f1235cd9b..76f0c827c2a 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -10196,6 +10196,13 @@ static const get_attributes_t get_attributes[] = {
static void test_get_attributes(void) { + const WCHAR *namespaces[] = + { + L"xmlns:oslc_am", + L"xmlns:rdf", + L"xmlns:dcterms", + L"xmlns:foaf" + }; const get_attributes_t *entry = get_attributes; IXMLDOMNamedNodeMap *map; IXMLDOMDocument *doc, *doc2; @@ -10205,7 +10212,7 @@ static void test_get_attributes(void) HRESULT hr; VARIANT v; BSTR str; - LONG length; + LONG length, i;
doc = create_document(&IID_IXMLDOMDocument);
@@ -10434,6 +10441,49 @@ static void test_get_attributes(void) }
IXMLDOMDocument_Release(doc); + + str = SysAllocString(L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + L"<rdf:RDF xmlns:oslc_am="http://open-services.net/ns/am#%5C"" + L" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#%5C"" + L" xmlns:dcterms="http://purl.org/dc/terms/%5C"" + L" xmlns:foaf="http://xmlns.com/foaf/0.1/%5C" >" + L"</rdf:RDF>"); + + doc = create_document(&IID_IXMLDOMDocument2); + + hr = IXMLDOMDocument_loadXML(doc, str, &b); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(b == VARIANT_TRUE, "got %d\n", b); + + hr = IXMLDOMDocument_get_documentElement(doc, &elem); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDOMElement_get_attributes(elem, &map); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + length = -1; + hr = IXMLDOMNamedNodeMap_get_length(map, &length); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(length == 4, "length %#lx.\n", length); + + for(i=0; i < length; i++) + { + hr = IXMLDOMNamedNodeMap_get_item(map, i, &node2); + ok( hr == S_OK, "Unexpected hr %#lx (%ld).\n", hr, i); + + hr = IXMLDOMNode_get_nodeName(node2, &str); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(str, namespaces[i]), "got %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IXMLDOMNode_Release(node2); + } + + IXMLDOMNamedNodeMap_Release(map); + IXMLDOMElement_Release(elem); + + IXMLDOMDocument_Release(doc); + free_bstrs(); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=150345
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 00000000004300F4, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032
Report validation errors: d3d11:d3d11 has no test summary line (early exit of the main process?) d3d11:d3d11 has unaccounted for todo messages d3d11:d3d11 returned a non-zero exit code despite reporting no failures