Jacek Caban : mshtml: Fixed handling NULL argument in IHTMLElement:: contains implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 18 16:08:49 CDT 2014


Module: wine
Branch: master
Commit: 7c7a594692406182ddb1fc44fc45221e06de4be3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7c7a594692406182ddb1fc44fc45221e06de4be3

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Aug 18 17:32:27 2014 +0200

mshtml: Fixed handling NULL argument in IHTMLElement::contains implementation.

---

 dlls/mshtml/htmlelem.c  | 24 ++++++++++++------------
 dlls/mshtml/tests/dom.c |  1 +
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index a02baa7..363a89a 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -882,22 +882,22 @@ static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pC
                                            VARIANT_BOOL *pfResult)
 {
     HTMLElement *This = impl_from_IHTMLElement(iface);
-    HTMLElement *child;
-    cpp_bool result;
-    nsresult nsres;
+    cpp_bool result = FALSE;
 
     TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
 
-    child = unsafe_impl_from_IHTMLElement(pChild);
-    if(!child) {
-        ERR("not our element\n");
-        return E_FAIL;
-    }
+    if(pChild) {
+        HTMLElement *child;
+        nsresult nsres;
 
-    nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
-    if(NS_FAILED(nsres)) {
-        ERR("failed\n");
-        return E_FAIL;
+        child = unsafe_impl_from_IHTMLElement(pChild);
+        if(!child) {
+            ERR("not our element\n");
+            return E_FAIL;
+        }
+
+        nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
+        assert(nsres == NS_OK);
     }
 
     *pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index f558c69..05f58a3 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -6913,6 +6913,7 @@ static void test_elems(IHTMLDocument2 *doc)
         test_elem_contains(elem, elem3, VARIANT_FALSE);
         test_elem_contains(elem, elem2, VARIANT_FALSE);
         test_elem_contains(elem, elem, VARIANT_TRUE);
+        test_elem_contains(elem, NULL, VARIANT_FALSE);
         IHTMLElement_Release(elem2);
 
         elem2 = test_elem_get_parent((IUnknown*)elem3);




More information about the wine-cvs mailing list