[BP] MB-20598: AddressSanitizer problems 06/68106/3
authorJim Walker <jim@couchbase.com>
Fri, 19 Aug 2016 15:19:51 +0000 (15:19 +0000)
committerDave Rigby <daver@couchbase.com>
Thu, 29 Sep 2016 11:38:21 +0000 (11:38 +0000)
Two leaks and one stack overflow.

The forest-kvstore code should use dynamic_cast (like couch-kvstore)
else when the incoming callback is not a RememberingCallback, we will
access outside of the incoming object.

ep_testsuite has a leak in tap code where we must release items
during iteration.

Change-Id: If0db9e936ee141299c5a579235e828c7309b8118
Reviewed-on: http://review.couchbase.org/68106
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
src/forest-kvstore/forest-kvstore.cc
tests/ep_testsuite.cc

index 8a7724d..19b68ca 100644 (file)
@@ -512,7 +512,7 @@ void ForestKVStore::getWithHeader(void *dbHandle, const std::string &key,
                                   bool fetchDelete) {
     fdb_file_handle *dbFileHandle = (fdb_file_handle *)dbHandle;
     RememberingCallback<GetValue> *rc =
-                       static_cast<RememberingCallback<GetValue> *>(&cb);
+                       dynamic_cast<RememberingCallback<GetValue> *>(&cb);
     bool getMetaOnly = rc && rc->val.isPartial();
     GetValue rv;
     fdb_kvs_handle *kvsHandle = NULL;
index e2f1ed0..7932290 100644 (file)
@@ -5750,7 +5750,7 @@ static enum test_result test_mb17517_tap_with_locked_key(ENGINE_HANDLE *h,
                         "Got CAS of -1 in TAP_MUTATION\n");
                 return FAIL;
             }
-
+            h1->release(h, NULL, it);
             testHarness.lock_cookie(cookie);
             break;
         }