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
This commit is contained in:
parent
06a2dcebea
commit
b11a8b1b9a
@ -1317,10 +1317,9 @@ TEST_F(DBTest2, CompressionFailures) {
|
|||||||
if (curr_compression_failure_type == kTestDecompressionCorruption) {
|
if (curr_compression_failure_type == kTestDecompressionCorruption) {
|
||||||
BlockContents* contents = static_cast<BlockContents*>(arg);
|
BlockContents* contents = static_cast<BlockContents*>(arg);
|
||||||
// Ensure uncompressed data != original data
|
// Ensure uncompressed data != original data
|
||||||
std::unique_ptr<char[]> fake_data(
|
const size_t len = contents->data.size() + 1;
|
||||||
new char[contents->data.size() + 1]);
|
std::unique_ptr<char[]> fake_data(new char[len]());
|
||||||
*contents =
|
*contents = BlockContents(std::move(fake_data), len);
|
||||||
BlockContents(std::move(fake_data), contents->data.size() + 1);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user