From 2ae91c6097002f98fddae29769bdcc7bfe8d4ec9 Mon Sep 17 00:00:00 2001 From: Zhichao Cao Date: Mon, 30 Mar 2020 14:08:55 -0700 Subject: [PATCH] Fix potential memory leak in table_test (#6611) Summary: The checksum generator should be released if file_writer fails to reset the pointer. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6611 Test Plan: pass make asan_check Reviewed By: riversand963 Differential Revision: D20742964 Pulled By: zhichao-cao fbshipit-source-id: cde41be2edb3d1e56083c2b93e1510fb32556146 --- table/table_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/table/table_test.cc b/table/table_test.cc index 0a6a810fc..61378d771 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -1190,6 +1190,8 @@ class FileChecksumTestHelper { void SetFileChecksumGenerator(FileChecksumGenerator* checksum_generator) { if (file_writer_ != nullptr) { file_writer_->TEST_SetFileChecksumGenerator(checksum_generator); + } else { + delete checksum_generator; } }