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
id result = [[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )];
NSString* resultAsString;
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];
NSString* className = NSStringFromClass([result class]);
if ([className isEqualToString:@"NSCFNumber"])
resultAsString = [NSString stringWithFormat:@"%@", result];
else if ([className isEqualToString:@"WebScriptObject"])
resultAsString = [result stringRepresentation];
else
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){
}
void wxWebKitCtrl::OnSize(wxSizeEvent &event){