[Mac] Address some clang static analyzer warnings in WebKit
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Sep 2016 07:18:48 +0000 (07:18 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Sep 2016 07:18:48 +0000 (07:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161597

Reviewed by Darin Adler.

Source/WebKit/mac:

* Misc/WebIconDatabase.h:
Remove unused instance variable. It has not been used since r16005 (2006)!

* Misc/WebSharingServicePickerController.mm:
(-[WebSharingServicePickerController sharingServicePicker:sharingServicesForItems:mask:proposedSharingServices:]):
Address array leak.

* WebCoreSupport/WebSelectionServiceController.mm:
(WebSelectionServiceController::hasRelevantSelectionServices):
Address attachment and cell leak.

* WebView/WebFullScreenController.h:
* WebView/WebImmediateActionController.h:
Remove unused instance variables.

Source/WebKit2:

* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
(-[WKLayerHostView makeBackingLayer]):
* UIProcess/mac/WKSharingServicePickerDelegate.mm:
(-[WKSharingServicePickerDelegate sharingServicePicker:sharingServicesForItems:mask:proposedSharingServices:]):
* WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
(-[WKDOMRange rangeByExpandingToWordBoundaryByCharacters:inDirection:]):
Address leaks caught by the static analyzer.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205592 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebIconDatabase.h
Source/WebKit/mac/Misc/WebSharingServicePickerController.mm
Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm
Source/WebKit/mac/WebView/WebFullScreenController.h
Source/WebKit/mac/WebView/WebImmediateActionController.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm
Source/WebKit2/UIProcess/mac/WKSharingServicePickerDelegate.mm
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm

index 7273515..05fd20a 100644 (file)
@@ -1,3 +1,25 @@
+2016-09-07  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [Mac] Address some clang static analyzer warnings in WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=161597
+
+        Reviewed by Darin Adler.
+
+        * Misc/WebIconDatabase.h:
+        Remove unused instance variable. It has not been used since r16005 (2006)!
+
+        * Misc/WebSharingServicePickerController.mm:
+        (-[WebSharingServicePickerController sharingServicePicker:sharingServicesForItems:mask:proposedSharingServices:]):
+        Address array leak.
+
+        * WebCoreSupport/WebSelectionServiceController.mm:
+        (WebSelectionServiceController::hasRelevantSelectionServices):
+        Address attachment and cell leak.
+
+        * WebView/WebFullScreenController.h:
+        * WebView/WebImmediateActionController.h:
+        Remove unused instance variables.
+
 2016-09-07  Simon Fraser  <simon.fraser@apple.com>
 
         Enable the <meter> element on iOS
index 09d6619..f0a6011 100644 (file)
@@ -69,7 +69,6 @@ extern NSSize WebIconLargeSize;  // 128 x 128
 
 @private
     WebIconDatabasePrivate *_private;
-    BOOL _isClosing;
 }
 
 
index bdfb42f..6cc49cd 100644 (file)
@@ -166,7 +166,7 @@ RetainPtr<NSImage> WebSharingServicePickerClient::imageForCurrentSharingServiceP
     if (_includeEditorServices)
         return proposedServices;
         
-    NSMutableArray *services = [[NSMutableArray alloc] initWithCapacity:[proposedServices count]];
+    NSMutableArray *services = [NSMutableArray arrayWithCapacity:proposedServices.count];
     
     for (NSSharingService *service in proposedServices) {
         if (service.type != NSSharingServiceTypeEditor)
index 62d3e05..f1fefcd 100644 (file)
@@ -80,15 +80,14 @@ bool WebSelectionServiceController::hasRelevantSelectionServices(bool isTextOnly
     if (isTextOnly && hasSelectionServices)
         return true;
 
-    NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
-    RetainPtr<NSImage> image = adoptNS([[NSImage alloc] init]);
-    NSTextAttachmentCell *cell = [[NSTextAttachmentCell alloc] initImageCell:image.get()];
-    [attachment setAttachmentCell:cell];
-    RetainPtr<NSMutableAttributedString> attributedStringWithRichContent = (NSMutableAttributedString *)[NSMutableAttributedString attributedStringWithAttachment:attachment];
+    auto attachment = adoptNS([[NSTextAttachment alloc] init]);
+    auto image = adoptNS([[NSImage alloc] init]);
+    auto cell = adoptNS([[NSTextAttachmentCell alloc] initImageCell:image.get()]);
+    [attachment setAttachmentCell:cell.get()];
+    NSMutableAttributedString *attributedStringWithRichContent = (NSMutableAttributedString *)[NSMutableAttributedString attributedStringWithAttachment:attachment.get()];
     [attributedStringWithRichContent appendAttributedString:attributedString.get()];
 
-    bool hasRichContentServices = hasCompatibleServicesForItems(@[ attributedStringWithRichContent.get() ]);
-    return hasRichContentServices;
+    return hasCompatibleServicesForItems(@[ attributedStringWithRichContent ]);
 }
 
 void WebSelectionServiceController::sharingServicePickerWillBeDestroyed(WebSharingServicePickerController &)
index cd53ba6..4981a21 100644 (file)
@@ -55,7 +55,6 @@ namespace WebCore {
     BOOL _isEnteringFullScreen;
     BOOL _isExitingFullScreen;
     BOOL _isFullScreen;
-    BOOL _isPlaying;
 }
 
 @property (readonly) NSRect initialFrame;
index ddd6c22..5128763 100644 (file)
@@ -51,7 +51,6 @@ struct DictionaryPopupInfo;
 
     RetainPtr<QLPreviewMenuItem> _currentQLPreviewMenuItem;
     RetainPtr<DDActionContext> _currentActionContext;
-    BOOL _isShowingTextIndicator;
     BOOL _hasActivatedActionContext;
     BOOL _contentPreventsDefault;
 }
index 8eb7192..ad7000a 100644 (file)
@@ -1,3 +1,18 @@
+2016-09-07  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [Mac] Address some clang static analyzer warnings in WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=161597
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
+        (-[WKLayerHostView makeBackingLayer]):
+        * UIProcess/mac/WKSharingServicePickerDelegate.mm:
+        (-[WKSharingServicePickerDelegate sharingServicePicker:sharingServicesForItems:mask:proposedSharingServices:]):
+        * WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
+        (-[WKDOMRange rangeByExpandingToWordBoundaryByCharacters:inDirection:]):
+        Address leaks caught by the static analyzer.
+
 2016-09-07  Zan Dobersek  <zdobersek@igalia.com>
 
         [GTK] Remove stale WebSoupRequestManager headers
index 012c79e..bc64ad7 100644 (file)
@@ -57,7 +57,7 @@
 #else
 - (CALayer *)makeBackingLayer
 {
-    return [[CALayerHost alloc] init];
+    return [[[CALayerHost alloc] init] autorelease];
 }
 #endif
 
index 1a8d810..fe1081c 100644 (file)
@@ -74,7 +74,7 @@
     if (!_filterEditingServices)
         return proposedServices;
 
-    NSMutableArray *services = [[NSMutableArray alloc] initWithCapacity:[proposedServices count]];
+    NSMutableArray *services = [NSMutableArray arrayWithCapacity:proposedServices.count];
     
     for (NSSharingService *service in proposedServices) {
         if (service.type != NSSharingServiceTypeEditor)
index 0f08d84..a2fb5a0 100644 (file)
 {
     RefPtr<WebCore::Range> newRange = rangeExpandedByCharactersInDirectionAtWordBoundary(direction == WKDOMRangeDirectionForward ?  _impl->endPosition() : _impl->startPosition(), characters, direction == WKDOMRangeDirectionForward ? WebCore::DirectionForward : WebCore::DirectionBackward);
 
-    return [[WKDOMRange alloc] _initWithImpl:newRange.get()];
+    return [[[WKDOMRange alloc] _initWithImpl:newRange.get()] autorelease];
 }
 
 @end