small bug in mshtml component

Andrey Turkin pancha at
Fri Oct 20 12:20:13 CDT 2006


Just found a bug in mshtml component get_body method implementation. If
one call it right after creation of CLSID_HTMLDocument instance, then it
would return success and pass NULL as body object. Native would return
"empty" body object instead. Native atl.dll library uses this behavior
and because of this segfaults.
I'm not acquainted with mshtml code enough to provide bug fix or even
test patch (I mean "proper" test). Here is quick-n-dirty test instead:

void test_for_body(void)
    HRESULT hr;
    IHTMLDocument *doc;
    IHTMLDocument2 *doc2;
    IPersistStreamInit *psi;
    IHTMLElement *body;

    hr = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_SERVER,
&IID_IHTMLDocument, (void**)&doc);
    ok( SUCCEEDED(hr), "CoCreateInstance failed:%08x\n", hr);
    hr = IHTMLDocument_QueryInterface(doc, &IID_IPersistStreamInit,
    ok( SUCCEEDED(hr), "QI PSI failed %08x\n", hr );
    IPersistStreamInit_InitNew( psi );
    IPersistStreamInit_Release( psi );
    hr = IHTMLDocument_QueryInterface(doc, &IID_IHTMLDocument2,
    IHTMLDocument_Release( doc );
    ok( SUCCEEDED(hr), "QI HD2 failed %08x\n", hr );
    hr = IHTMLDocument2_get_body( doc2, &body);
    IHTMLDocument2_Release( doc2 );
    ok( SUCCEEDED(hr), "get_body failed %08x\n", hr );
    ok( body != NULL, "get_body returned NULL\n" );
    if ( body != NULL )
	IHTMLElement_Release( body );

I hope a man with good mshtml knowledge would easily turn this test into
neat small test in few minutes.

  Andrey Turkin

More information about the wine-devel mailing list