From: Vadim Zeitlin Date: Wed, 29 Sep 2010 13:46:24 +0000 (+0000) Subject: Fix crash in wxWebKitCtrl when using JavaScript. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4267872212359599cbc60a12d10f9c6f6173b947?hp=c85a79963da3c3c9b58c306b3408bf4ac86eec7d Fix crash in wxWebKitCtrl when using JavaScript. Ignore the unknown types of the script result, in particular don't crash trying to dereference an uninitialized pointer if the script didn't return anything. Closes #12361. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65673 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index 6f6ecbc845..9a79c6ab08 100644 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -684,7 +684,6 @@ wxString wxWebKitCtrl::RunScript(const wxString& javascript){ id result = [[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )]; NSString* resultAsString; - wxString resultAsWxString = wxEmptyString; NSString* className = NSStringFromClass([result class]); if ([className isEqualToString:@"NSCFNumber"]) resultAsString = [NSString stringWithFormat:@"%@", result]; @@ -699,10 +698,9 @@ wxString wxWebKitCtrl::RunScript(const wxString& javascript){ else if ([className isEqualToString:@"WebScriptObject"]) resultAsString = [result stringRepresentation]; else - fprintf(stderr, "wxWebKitCtrl::RunScript - Unexpected return type: %s!\n", [className UTF8String]); + return wxString(); // This can happen, see e.g. #12361. - resultAsWxString = wxStringWithNSString( resultAsString ); - return resultAsWxString; + return wxStringWithNSString( resultAsString ); } void wxWebKitCtrl::OnSize(wxSizeEvent &event){