[iOS] Fix warnings about leaks found by clang static analyzer
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 May 2018 04:21:09 +0000 (04:21 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 May 2018 04:21:09 +0000 (04:21 +0000)
commitb70be5b8679e82ff3b71444df8c0efe2b7d02a1f
tree12a944c91e035c4887c1fce7243f00a2966157e1
parentd2c1dd0792f1ad0757e7a895367f32bb590d3574
[iOS] Fix warnings about leaks found by clang static analyzer
<https://webkit.org/b/186009>
<rdar://problem/40574267>

Reviewed by Daniel Bates.

Source/ThirdParty/libwebrtc:

* Source/third_party/opus/src/src/opus_compare.c:
* Source/third_party/opus/src/src/opus_demo.c:
(main):
- Free allocated memory on early returns.
* Source/third_party/usrsctp/usrsctplib/user_mbuf.c:
(clust_constructor_dup):
(mb_ctor_clust):
- Free allocated memory if `m` is NULL.
* Source/third_party/usrsctp/usrsctplib/user_socket.c:
(usrsctp_connect): Free `sa` memory if getsockaddr() returns an
error, but still allocates memory for `sa`.
* WebKit/patch-opus.diff: Add patch for opus changes.
* WebKit/patch-usrsctp: Rename empty file to patch-usrsctp.diff.
* WebKit/patch-usrsctp.diff: Add patch for usrsctp changes.
* libwebrtc.xcodeproj/project.pbxproj: Remove opus_compare.c,
opus_demo.c, and repacketizer_demo.c from opus target.  This
code is for stand-alone tools, and although it may be removed
during dead code linking, we don't need to spend time compiling
it.

Source/WebCore:

* Modules/webauthn/cocoa/LocalAuthenticator.mm:
(WebCore::LocalAuthenticator::makeCredential):
(WebCore::LocalAuthenticator::getAssertion):
(WebCore::LocalAuthenticator::issueClientCertificate const):
- Don't leak CF objects in early return paths, and get rid of
  `retained*` variables, by making original variables use
  RetainPtr<>.
* bridge/objc/WebScriptObject.mm:
(+[WebUndefined allocWithZone:]): Modernize WebUndefined by
using NeverDestroyed<RetainPr<WebUndefined>> type.  Explicitly
retain the object returned on each call.
(+[WebUndefined undefined]): Explicitly autorelease the object
returned.  Note that neither of these changes fixes the static
analyzer warnings in this source file.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::exernalDeviceDisplayNameForPlayer): Use RetainPtr<> to
stop leaking NSString objects in a loop.
* platform/ios/wak/WAKWindow.h:
(-[WAKWindow _newFirstResponderAfterResigning]): Mark as
NS_RETURNS_NOT_RETAINED like the corresponding AppKit method
since this doesn't return a new object.  This fixes some
false-positive leaks warnings.

Source/WebKit:

* UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
(WebKit::WebAutomationSession::platformSimulateKeySequence): Fix
leak of two WebEvent objects that happened in a loop.
* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDelegate previewController:transitionImageForPreviewItem:contentRect:]):
Fix leak of a UIImage.

Source/WebKitLegacy/mac:

* WebView/WebHTMLView.mm:
(-[WebHTMLView doCommandBySelector:]): Fix use of an
uninitialized boolean variable (`eventWasHandled`) that only
happened on iOS.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c
Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c
Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c
Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c
Source/ThirdParty/libwebrtc/WebKit/patch-opus.diff [new file with mode: 0644]
Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp [deleted file]
Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp.diff [new file with mode: 0644]
Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj
Source/WebCore/ChangeLog
Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm
Source/WebCore/bridge/objc/WebScriptObject.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/ios/wak/WAKWindow.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm
Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm