From 76609cd38a980d974a4872bba71d9fa820a4d6df Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Wed, 12 Aug 2020 12:01:42 -0700 Subject: [PATCH] Fix potential memory leak (#7245) Summary: ``` int* value = new int; ASSERT_NE(nullptr, value); ``` `ASSERT_NE` can expand the expression such that a memory leak is reported by clang analyzer. We can remove this ASSERT_NE since we can assume the memory allocation must succeed. Otherwise a bad alloc exception will be thrown and the process will be killed anyway. Test plan (dev server): ``` USE_CLANG=1 make analyze ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/7245 Reviewed By: jay-zhuang Differential Revision: D23079641 Pulled By: riversand963 fbshipit-source-id: a6739a903f90f8715f6f1ef3e5c8a329245b8e78 --- util/timer_test.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/util/timer_test.cc b/util/timer_test.cc index 0200cf69b..18b0b90c9 100644 --- a/util/timer_test.cc +++ b/util/timer_test.cc @@ -289,7 +289,6 @@ TEST_F(TimerTest, CancelRunningTask) { Timer timer(mock_env_.get()); ASSERT_TRUE(timer.Start()); int* value = new int; - ASSERT_NE(nullptr, value); // make linter happy *value = 0; SyncPoint::GetInstance()->DisableProcessing(); SyncPoint::GetInstance()->LoadDependency({ @@ -337,7 +336,6 @@ TEST_F(TimerTest, ShutdownRunningTask) { ASSERT_TRUE(timer.Start()); int* value = new int; - ASSERT_NE(nullptr, value); *value = 0; timer.Add( [&]() {