Fix valgrind error by init memory region (#6842)

Summary:
As title. After allocating a memory buffer, initialize its content to 0s.
This fixes valgrind issue introduced in https://github.com/facebook/rocksdb/issues/6709.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6842

Test Plan:
```
$make valgrind_test
$valgrind --tool=memcheck --track-origins=yes ./db_test2 --gtest_filter=DBTest2.CompressionFailures
```

Reviewed By: pdillinger

Differential Revision: D21551848

Pulled By: riversand963

fbshipit-source-id: e87a6f413e3f3d92d8e23d8ecc4cf93479c6674c
main
Yanqin Jin 5 years ago committed by Facebook GitHub Bot
parent 06a2dcebea
commit b11a8b1b9a
  1. 7
      db/db_test2.cc

@ -1317,10 +1317,9 @@ TEST_F(DBTest2, CompressionFailures) {
if (curr_compression_failure_type == kTestDecompressionCorruption) {
BlockContents* contents = static_cast<BlockContents*>(arg);
// Ensure uncompressed data != original data
std::unique_ptr<char[]> fake_data(
new char[contents->data.size() + 1]);
*contents =
BlockContents(std::move(fake_data), contents->data.size() + 1);
const size_t len = contents->data.size() + 1;
std::unique_ptr<char[]> fake_data(new char[len]());
*contents = BlockContents(std::move(fake_data), len);
}
});

Loading…
Cancel
Save