From 8d9bbf2c5c8098633aff9b3770530f960dd2298f Mon Sep 17 00:00:00 2001 From: Jefferson Carpenter Date: Thu, 27 May 2021 12:40:08 +0000 Subject: [PATCH 2/2] msxml3: Null check newNode in domelem insertBefore. Signed-off-by: Jefferson Carpenter --- dlls/msxml3/element.c | 2 ++ dlls/msxml3/tests/domdoc.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index 05255508d4e..5891653a76f 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -309,6 +309,8 @@ static HRESULT WINAPI domelem_insertBefore( TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), old_node); + if (!newNode) return E_INVALIDARG; + hr = IXMLDOMNode_get_nodeType(newNode, &type); if (hr != S_OK) return hr; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 0cc4d9c3c24..80c5cd530bb 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -9416,6 +9416,13 @@ static void test_insertBefore(void) todo_wine EXPECT_REF(elem2, 2); + /* NULL to element */ + V_VT(&v) = VT_NULL; + node = (void*)0xdeadbeef; + hr = IXMLDOMElement_insertBefore(elem1, NULL, v, &node); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(node == (void*)0xdeadbeef, "got %p\n", node); + /* document to element */ V_VT(&v) = VT_DISPATCH; V_DISPATCH(&v) = NULL; -- 2.26.2