Title: [250497] trunk/Source/WTF
Revision
250497
Author
krol...@apple.com
Date
2019-09-29 19:21:48 -0700 (Sun, 29 Sep 2019)

Log Message

Address static analysis warning in ParkingLot.cpp: Access to field 'size' results in a dereference of a null pointer
https://bugs.webkit.org/show_bug.cgi?id=202154
<rdar://problem/55672103>

Reviewed by Brent Fulgham.

Static analysis reports the following:

    .../OpenSource/Source/WTF/wtf/ParkingLot.cpp:376:30: warning: Access to field 'size' results in a dereference of a null pointer (loaded from variable 'oldHashtable')
        RELEASE_ASSERT(newSize > oldHashtable->size);
                                 ^~~~~~~~~~~~~~~~~~

This warning arises because earlier code checks to see if oldHashtable
is NULL, leading the static analyzer to think that it *could* be NULL.
However, even earlier code actually ensures that oldHashtable will not
be NULL. Address this by removing the NULL check, and back it up with
an ASSERT to ensure that it's not NULL.

* wtf/ParkingLot.cpp:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (250496 => 250497)


--- trunk/Source/WTF/ChangeLog	2019-09-30 01:56:43 UTC (rev 250496)
+++ trunk/Source/WTF/ChangeLog	2019-09-30 02:21:48 UTC (rev 250497)
@@ -1,3 +1,25 @@
+2019-09-29  Keith Rollin  <krol...@apple.com>
+
+        Address static analysis warning in ParkingLot.cpp: Access to field 'size' results in a dereference of a null pointer
+        https://bugs.webkit.org/show_bug.cgi?id=202154
+        <rdar://problem/55672103>
+
+        Reviewed by Brent Fulgham.
+
+        Static analysis reports the following:
+
+            .../OpenSource/Source/WTF/wtf/ParkingLot.cpp:376:30: warning: Access to field 'size' results in a dereference of a null pointer (loaded from variable 'oldHashtable')
+                RELEASE_ASSERT(newSize > oldHashtable->size);
+                                         ^~~~~~~~~~~~~~~~~~
+
+        This warning arises because earlier code checks to see if oldHashtable
+        is NULL, leading the static analyzer to think that it *could* be NULL.
+        However, even earlier code actually ensures that oldHashtable will not
+        be NULL. Address this by removing the NULL check, and back it up with
+        an ASSERT to ensure that it's not NULL.
+
+        * wtf/ParkingLot.cpp:
+
 2019-09-26  Alexey Shvayka  <shvaikal...@gmail.com>
 
         toExponential, toFixed, and toPrecision should allow arguments up to 100

Modified: trunk/Source/WTF/wtf/ParkingLot.cpp (250496 => 250497)


--- trunk/Source/WTF/wtf/ParkingLot.cpp	2019-09-30 01:56:43 UTC (rev 250496)
+++ trunk/Source/WTF/wtf/ParkingLot.cpp	2019-09-30 02:21:48 UTC (rev 250497)
@@ -355,7 +355,8 @@
     // Check again, since the hashtable could have rehashed while we were locking it. Also,
     // lockHashtable() creates an initial hashtable for us.
     oldHashtable = hashtable.load();
-    if (oldHashtable && static_cast<double>(oldHashtable->size) / static_cast<double>(numThreads) >= maxLoadFactor) {
+    RELEASE_ASSERT(oldHashtable);
+    if (static_cast<double>(oldHashtable->size) / static_cast<double>(numThreads) >= maxLoadFactor) {
         if (verbose)
             dataLog(toString(Thread::current(), ": after locking, no need to rehash because ", oldHashtable->size, " / ", numThreads, " >= ", maxLoadFactor, "\n"));
         unlockHashtable(bucketsToUnlock);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to