Add better error checking to wxWebViewIE
Verify that accessing a property really succeeded before using the returned value. This should fix at least one crash due to the use of uninitialized BSTR in wxWebViewIE::GetCurrentTitle(). Closes #17204.
This commit is contained in:
parent
8ce5b9099b
commit
4489ec80e0
@ -232,8 +232,8 @@ wxString wxWebViewIE::GetPageSource() const
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
BSTR bstr;
|
||||
htmlTag->get_outerHTML(&bstr);
|
||||
source = wxString(bstr);
|
||||
if ( htmlTag->get_outerHTML(&bstr) == S_OK )
|
||||
source = wxString(bstr);
|
||||
}
|
||||
}
|
||||
return source;
|
||||
@ -573,16 +573,15 @@ wxString wxWebViewIE::GetCurrentTitle() const
|
||||
{
|
||||
wxCOMPtr<IHTMLDocument2> document(GetDocument());
|
||||
|
||||
wxString s;
|
||||
if(document)
|
||||
{
|
||||
BSTR title;
|
||||
document->get_nameProp(&title);
|
||||
return wxString(title);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
if ( document->get_nameProp(&title) == S_OK )
|
||||
s = title;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool wxWebViewIE::CanCut() const
|
||||
@ -707,16 +706,13 @@ bool wxWebViewIE::IsEditable() const
|
||||
if(document)
|
||||
{
|
||||
BSTR mode;
|
||||
document->get_designMode(&mode);
|
||||
if(wxString(mode) == "On")
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
if ( document->get_designMode(&mode) == S_OK )
|
||||
{
|
||||
if ( wxString(mode) == "On" )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxWebViewIE::SelectAll()
|
||||
@ -736,8 +732,8 @@ bool wxWebViewIE::HasSelection() const
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
BSTR type;
|
||||
selection->get_type(&type);
|
||||
sel = wxString(type);
|
||||
if ( selection->get_type(&type) == S_OK )
|
||||
sel = wxString(type);
|
||||
}
|
||||
return sel != "None";
|
||||
}
|
||||
@ -772,8 +768,8 @@ wxString wxWebViewIE::GetSelectedText() const
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
BSTR text;
|
||||
range->get_text(&text);
|
||||
selected = wxString(text);
|
||||
if ( range->get_text(&text) == S_OK )
|
||||
selected = wxString(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -805,8 +801,8 @@ wxString wxWebViewIE::GetSelectedSource() const
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
BSTR text;
|
||||
range->get_htmlText(&text);
|
||||
selected = wxString(text);
|
||||
if ( range->get_htmlText(&text) == S_OK )
|
||||
selected = wxString(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -846,8 +842,8 @@ wxString wxWebViewIE::GetPageText() const
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
BSTR out;
|
||||
body->get_innerText(&out);
|
||||
text = wxString(out);
|
||||
if ( body->get_innerText(&out) == S_OK )
|
||||
text = wxString(out);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user