[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    mshtml #5: Don't assume that nselem is valid in HTMLElement.
From:       Jacek Caban <jacek () codeweavers ! com>
Date:       2008-04-30 16:18:46
Message-ID: 48189BE6.7090602 () codeweavers ! com
[Download RAW message or body]

---
  dlls/mshtml/htmlelem.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
  dlls/mshtml/htmlelem2.c |   10 ++++++++++
  2 files changed, 52 insertions(+), 0 deletions(-)

["1a6d75961da04fcd53aef6142ffb2cc2d5cb9966.diff" (text/x-patch)]

diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 0f56cfd..f450297 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -138,6 +138,11 @@ static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttr
 
     WARN("(%p)->(%s . %08x)\n", This, debugstr_w(strAttributeName), lFlags);
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     VariantInit(&AttributeValueChanged);
 
     hres = VariantChangeType(&AttributeValueChanged, &AttributeValue, 0, VT_BSTR);
@@ -178,6 +183,11 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
 
     WARN("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     V_VT(AttributeValue) = VT_NULL;
 
     nsAString_Init(&attr_str, strAttributeName);
@@ -245,6 +255,11 @@ static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
 
     TRACE("(%p)->(%p)\n", This, p);
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     nsAString_Init(&class_str, NULL);
     nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
 
@@ -286,6 +301,15 @@ static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
 
     TRACE("(%p)->(%p)\n", This, p);
 
+    if(!This->nselem) {
+        static const WCHAR comment_tagW[] = {'!',0};
+
+        WARN("NULL nselem, assuming comment\n");
+
+        *p = SysAllocString(comment_tagW);
+        return S_OK;
+    }
+
     nsAString_Init(&tag_str, NULL);
     nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
     if(NS_SUCCEEDED(nsres)) {
@@ -316,6 +340,11 @@ static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
 
     TRACE("(%p)->(%p)\n", This, p);
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle,
                                              (void**)&nselemstyle);
     if(NS_FAILED(nsres)) {
@@ -627,6 +656,11 @@ static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v)
 
     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
     if(NS_FAILED(nsres)) {
         ERR("Could not get nsIDOMNSHTMLElement: %08x\n", nsres);
@@ -702,6 +736,11 @@ static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsI
     static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
     nsresult nsres;
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     if (!strcmpiW(where, wszBeforeBegin))
     {
         nsIDOMNode *unused;
@@ -1513,6 +1552,9 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name)
 
     static const PRUnichar nameW[] = {'n','a','m','e',0};
 
+    if(!elem->nselem)
+        return FALSE;
+
     nsAString_Init(&nsstr, NULL);
     nsIDOMHTMLElement_GetId(elem->nselem, &nsstr);
     nsAString_GetData(&nsstr, &str);
diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c
index 01c88fa..4430703 100644
--- a/dlls/mshtml/htmlelem2.c
+++ b/dlls/mshtml/htmlelem2.c
@@ -651,6 +651,11 @@ static HRESULT WINAPI HTMLElement2_put_scrollTop(IHTMLElement2 *iface, long v)
 
     TRACE("(%p)->(%ld)\n", This, v);
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
     if(NS_SUCCEEDED(nsres)) {
         nsIDOMNSHTMLElement_SetScrollTop(nselem, v);
@@ -677,6 +682,11 @@ static HRESULT WINAPI HTMLElement2_put_scrollLeft(IHTMLElement2 *iface, long v)
 
     TRACE("(%p)->(%ld)\n", This, v);
 
+    if(!This->nselem) {
+        FIXME("NULL nselem\n");
+        return E_NOTIMPL;
+    }
+
     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
     if(NS_SUCCEEDED(nsres)) {
         nsIDOMNSHTMLElement_SetScrollLeft(nselem, v);





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic