Title: [261070] trunk/Source/WebCore
Revision
261070
Author
[email protected]
Date
2020-05-03 20:42:02 -0700 (Sun, 03 May 2020)

Log Message

Fix static analyzer false positive in -[WebUndefined undefined]
<https://webkit.org/b/211353>

Reviewed by Darin Adler.

* bridge/objc/WebScriptObject.mm:
(+[WebUndefined allocWithZone:]):
(-[WebUndefined initWithCoder:]):
(-[WebUndefined retain]):
(-[WebUndefined autorelease]):
- Update method signatures.
(+[WebUndefined undefined]):
- Fix clang static analyzer false positive by using idiomatic
  -alloc, -init calls to create object.  These methods call
  -allocWithZone:, so this still uses the singleton pattern.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (261069 => 261070)


--- trunk/Source/WebCore/ChangeLog	2020-05-03 22:37:19 UTC (rev 261069)
+++ trunk/Source/WebCore/ChangeLog	2020-05-04 03:42:02 UTC (rev 261070)
@@ -1,3 +1,21 @@
+2020-05-03  David Kilzer  <[email protected]>
+
+        Fix static analyzer false positive in -[WebUndefined undefined]
+        <https://webkit.org/b/211353>
+
+        Reviewed by Darin Adler.
+
+        * bridge/objc/WebScriptObject.mm:
+        (+[WebUndefined allocWithZone:]):
+        (-[WebUndefined initWithCoder:]):
+        (-[WebUndefined retain]):
+        (-[WebUndefined autorelease]):
+        - Update method signatures.
+        (+[WebUndefined undefined]):
+        - Fix clang static analyzer false positive by using idiomatic
+          -alloc, -init calls to create object.  These methods call
+          -allocWithZone:, so this still uses the singleton pattern.
+
 2020-05-03  Daniel Bates  <[email protected]>
 
         Sometimes cannot find <textarea> in list of editable elements

Modified: trunk/Source/WebCore/bridge/objc/WebScriptObject.mm (261069 => 261070)


--- trunk/Source/WebCore/bridge/objc/WebScriptObject.mm	2020-05-03 22:37:19 UTC (rev 261069)
+++ trunk/Source/WebCore/bridge/objc/WebScriptObject.mm	2020-05-04 03:42:02 UTC (rev 261070)
@@ -645,13 +645,11 @@
 
 @implementation WebUndefined
 
-+ (id)allocWithZone:(NSZone *)unusedZone
++ (instancetype)allocWithZone:(NSZone *)zone
 {
-    UNUSED_PARAM(unusedZone);
-
     static NeverDestroyed<RetainPtr<WebUndefined>> sharedUndefined;
     if (!sharedUndefined.get())
-        sharedUndefined.get() = adoptNS([super allocWithZone:nullptr]);
+        sharedUndefined.get() = adoptNS([super allocWithZone:zone]);
     return [sharedUndefined.get() retain];
 }
 
@@ -660,7 +658,7 @@
     return @"undefined";
 }
 
-- (id)initWithCoder:(NSCoder *)unusedCoder
+- (nullable instancetype)initWithCoder:(NSCoder *)unusedCoder
 {
     UNUSED_PARAM(unusedCoder);
 
@@ -679,7 +677,7 @@
     return self;
 }
 
-- (id)retain
+- (instancetype)retain
 {
     return self;
 }
@@ -693,7 +691,7 @@
     return NSUIntegerMax;
 }
 
-- (id)autorelease
+- (instancetype)autorelease
 {
     return self;
 }
@@ -707,7 +705,7 @@
 
 + (WebUndefined *)undefined
 {
-    return [[WebUndefined allocWithZone:NULL] autorelease];
+    return [[[WebUndefined alloc] init] autorelease];
 }
 
 @end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to