Make -[_WKAttachment setFileWrapper:contentType:completion:] robust when given a...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2019 03:59:21 +0000 (03:59 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2019 03:59:21 +0000 (03:59 +0000)
commitba25fda50836a07f4e6dc6baba2f31da5969654a
treea73fefac4402b69c15fd0b247a1ef34e03e2f56a
parent97f8ec4f4abe226b4c54fba0c11ef5e3206c1a20
Make -[_WKAttachment setFileWrapper:contentType:completion:] robust when given a nil completion handler
https://bugs.webkit.org/show_bug.cgi?id=195725
<rdar://problem/48545062>

Reviewed by Tim Horton.

Source/WebKit:

Add a missing nil check before invoking the given completionHandler in the case where the attachment is invalid.
Tested by augmenting WKAttachmentTests.SetFileWrapperForPDFImageAttachment to exercise this scenario.

* UIProcess/API/APIAttachment.cpp:
(API::Attachment::invalidate):

Additionally make sure that an invalidated _WKAttachment is also considered to be disconnected.

* UIProcess/API/Cocoa/_WKAttachment.mm:
(-[_WKAttachment setFileWrapper:contentType:completion:]):

Tools:

Test that we don't crash when changing the file wrapper of an invalid attachment, if the given completion
handler is nil.

* TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APIAttachment.cpp
Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm