[clusterfuzz] Length 0 is perfectly fine for BitVector.
authorbmeurer <bmeurer@chromium.org>
Fri, 8 May 2015 12:01:46 +0000 (05:01 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 8 May 2015 12:01:51 +0000 (12:01 +0000)
BUG=chromium:485952
LOG=n
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1124223006

Cr-Commit-Position: refs/heads/master@{#28316}

src/bit-vector.h

index eeda0e9..3703f28 100644 (file)
@@ -66,7 +66,7 @@ class BitVector : public ZoneObject {
       : length_(length),
         data_length_(SizeFor(length)),
         data_(zone->NewArray<uintptr_t>(data_length_)) {
-    DCHECK(length > 0);
+    DCHECK_LE(0, length);
     Clear();
   }
 
@@ -77,7 +77,10 @@ class BitVector : public ZoneObject {
     CopyFrom(other);
   }
 
-  static int SizeFor(int length) { return 1 + ((length - 1) / kDataBits); }
+  static int SizeFor(int length) {
+    if (length == 0) return 1;
+    return 1 + ((length - 1) / kDataBits);
+  }
 
   void CopyFrom(const BitVector& other) {
     DCHECK(other.length() <= length());