MB-21300: [Address Sanitizer] Prevent underflow during hash table resize() 87/68887/2
authorManu Dhundi <manu@couchbase.com>
Tue, 18 Oct 2016 20:51:10 +0000 (13:51 -0700)
committerManu Dhundi <manu@couchbase.com>
Tue, 18 Oct 2016 21:22:11 +0000 (21:22 +0000)
http://cv.jenkins.couchbase.com/job/ep-engine-addresssanitizer-master/385

If i == 0 in line 144 of HashTable::resize(), reading prime_size_table[i - 1]
is spurious.

Change-Id: I7f3135efff7a0993fb939707b912d064514e9a45
Reviewed-on: http://review.couchbase.org/68887
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
src/stored-value.cc

index f22cef4..cbde24d 100644 (file)
@@ -422,6 +422,8 @@ void HashTable::resize() {
     } else if (prime_size_table[i] < static_cast<ssize_t>(defaultNumBuckets)) {
         // Was going to be smaller than the configured ht_size.
         new_size = defaultNumBuckets;
+    } else if (0 == i) {
+        new_size = prime_size_table[i];
     } else if (isCurrently(size, prime_size_table[i-1], prime_size_table[i])) {
         // If one of the candidate sizes is the current size, maintain
         // the current size in order to remain stable.