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
main
Yanqin Jin 4 years ago committed by Facebook GitHub Bot
parent 378bc94d7e
commit 76609cd38a
  1. 2
      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(
[&]() {

Loading…
Cancel
Save