mshtml: Correctly handle NULL nsdoc in IHTMLDocument2::get_body.

This commit is contained in:
Jacek Caban 2010-11-14 14:42:55 +01:00 committed by Alexandre Julliard
parent 22ba44b401
commit c481fb4bb8
2 changed files with 13 additions and 10 deletions

View File

@ -140,19 +140,17 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement
HTMLDocument *This = HTMLDOC_THIS(iface); HTMLDocument *This = HTMLDOC_THIS(iface);
nsIDOMHTMLElement *nsbody = NULL; nsIDOMHTMLElement *nsbody = NULL;
HTMLDOMNode *node; HTMLDOMNode *node;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(!This->doc_node->nsdoc) { if(This->doc_node->nsdoc) {
WARN("NULL nsdoc\n"); nsresult nsres;
return E_UNEXPECTED;
}
nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody); nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
TRACE("Could not get body: %08x\n", nsres); TRACE("Could not get body: %08x\n", nsres);
return E_UNEXPECTED; return E_UNEXPECTED;
}
} }
if(nsbody) { if(nsbody) {

View File

@ -6972,7 +6972,7 @@ static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
static void test_docfrag(IHTMLDocument2 *doc) static void test_docfrag(IHTMLDocument2 *doc)
{ {
IHTMLElement *div, *br; IHTMLElement *div, *body, *br;
IHTMLElementCollection *col; IHTMLElementCollection *col;
IHTMLDocument2 *frag; IHTMLDocument2 *frag;
HRESULT hres; HRESULT hres;
@ -6990,6 +6990,11 @@ static void test_docfrag(IHTMLDocument2 *doc)
test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]"); test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
body = (void*)0xdeadbeef;
hres = IHTMLDocument2_get_body(frag, &body);
ok(hres == S_OK, "get_body failed: %08x\n", hres);
ok(!body, "body != NULL\n");
br = test_create_elem(doc, "BR"); br = test_create_elem(doc, "BR");
test_node_append_child((IUnknown*)frag, (IUnknown*)br); test_node_append_child((IUnknown*)frag, (IUnknown*)br);
IHTMLElement_Release(br); IHTMLElement_Release(br);