Jacek Caban : mshtml: Don't assume that nselem is valid in HTMLElement.

Alexandre Julliard julliard at winehq.org
Thu May 1 06:38:38 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Apr 30 18:18:46 2008 +0200

mshtml: Don't assume that nselem is valid in HTMLElement.

---

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

diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index f87bb44..39e8ebb 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);




More information about the wine-cvs mailing list