Don't crash in wxWebView under OS X if custom URI is invalid.
Don't assume that wxWebViewHandler::GetFile() always returns a valid pointer, it may fail and return NULL, e.g. for a non-existent VFS location. Closes #15254. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74239 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1291,9 +1291,23 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
NSURLRequest *request = [self request];
|
NSURLRequest *request = [self request];
|
||||||
NSString* path = [[request URL] absoluteString];
|
NSString* path = [[request URL] absoluteString];
|
||||||
|
|
||||||
|
id<NSURLProtocolClient> client = [self client];
|
||||||
|
|
||||||
wxString wxpath = wxStringWithNSString(path);
|
wxString wxpath = wxStringWithNSString(path);
|
||||||
wxString scheme = wxStringWithNSString([[request URL] scheme]);
|
wxString scheme = wxStringWithNSString([[request URL] scheme]);
|
||||||
wxFSFile* file = g_stringHandlerMap[scheme]->GetFile(wxpath);
|
wxFSFile* file = g_stringHandlerMap[scheme]->GetFile(wxpath);
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
NSError *error = [[NSError alloc] initWithDomain:NSURLErrorDomain
|
||||||
|
code:NSURLErrorFileDoesNotExist
|
||||||
|
userInfo:nil];
|
||||||
|
|
||||||
|
[client URLProtocol:self didFailWithError:error];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
size_t length = file->GetStream()->GetLength();
|
size_t length = file->GetStream()->GetLength();
|
||||||
|
|
||||||
|
|
||||||
@@ -1307,8 +1321,6 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
file->GetStream()->Read(buffer, length);
|
file->GetStream()->Read(buffer, length);
|
||||||
NSData *data = [[NSData alloc] initWithBytesNoCopy:buffer length:length];
|
NSData *data = [[NSData alloc] initWithBytesNoCopy:buffer length:length];
|
||||||
|
|
||||||
id<NSURLProtocolClient> client = [self client];
|
|
||||||
|
|
||||||
//We do not support caching anything yet
|
//We do not support caching anything yet
|
||||||
[client URLProtocol:self didReceiveResponse:response
|
[client URLProtocol:self didReceiveResponse:response
|
||||||
cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
||||||
|
Reference in New Issue
Block a user