#15254 closed defect (fixed)

wxWebViewHandler::GetFile() assumed to return non NULL.

Reported by: sentieshar Owned by:
Priority: normal Milestone:
Component: WebView Version: stable-latest
Keywords: wxWebViewWebKit Cc:
Blocked By: Blocking:
Patch: yes

Description

In osx/webview_webkit.mm, in the implementation of WebViewCustomProtocol startLoading, the result of GetFile is assumed to be non NULL. The msw and gtk WebView implementations appear to check for and handle NULL results. You can check the behaviour by running the webview sample and attempting to load a nonexistent location from the wxWebViewFSHandler "memory", such as "memory:test". The resulting backtrace is:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000010
[Switching to process 980 thread 0x4f03]
wxFSFile::GetStream (this=0x0) at filesys.h:63
63 wxInputStream *GetStream() const { return m_Stream; }
(gdb) bt
# 0 wxFSFile::GetStream (this=0x0) at filesys.h:63
# 1 0x000000010001aedd in -[WebViewCustomProtocol startLoading] (self=0x101e514b0, _cmd=0x7fff91bd37b4) at ../../src/wxWidgets-svn/src/osx/webview_webkit.mm:1297
# 2 0x00007fff9033fae1 in -[NSBlockOperation main] ()
# 3 0x00007fff903066b4 in -[NSOperationInternal start] ()
# 4 0x00007fff9036528d in -[_NSCFURLProtocolBridgeWithTrampoline processEventQ] ()
# 5 0x00007fff97c86dfc in
CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK ()
# 6 0x00007fff97c3ef02 in
CFRunLoopDoBlocks ()
# 7 0x00007fff97c66b66 in CFRunLoopRun ()
# 8 0x00007fff97c66486 in CFRunLoopRunSpecific ()
# 9 0x00007fff90323fd7 in +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] ()
# 10 0x00007fff9031872a in -[NSThread main] ()
# 11 0x00007fff903186a2 in
NSThreadmain ()
# 12 0x00007fff8fe228bf in _pthread_start ()
# 13 0x00007fff8fe25b75 in thread_start ()

Attachments (1)

webview-webkit-handle-null-getfile.patch download (1.2 KB) - added by sentieshar 14 months ago.
If GetFile returns NULL then indicate that the request failed.

Download all attachments as: .zip

Change History (3)

Changed 14 months ago by sentieshar

If GetFile returns NULL then indicate that the request failed.

comment:1 Changed 14 months ago by sentieshar

  • Patch set

This minimal patch checks if GetFile() returns NULL and in that case calls NSURLProtocolClient -URLProtocol: didFailWithError:. The error uses is a NSURLErrorFileDoesNotExist (this seemed reasonably appropriate).

comment:2 Changed 14 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74239]) 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.

Note: See TracTickets for help on using tickets.