summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2018-05-15 16:05:47 -0700
committerGeorge Burgess IV <gbiv@google.com>2018-05-15 16:09:23 -0700
commitbf87258189b0ca6e6273cf20c27af7dfc2599ce7 (patch)
treef0f154873c02a70a14bdfb37ba4ada0099cd457f /tests
parenta1b34a8173609094df0e124ecca19b619fc19a41 (diff)
downloadextras-bf87258189b0ca6e6273cf20c27af7dfc2599ce7.tar.gz
Fix a memory leak
If setpriority failed, we wouldn't free this. Just use a unique_ptr to handle the lifetime for us. Caught by the static analyzer. Bug: None Test: Built. Static analyzer seems happy now. Change-Id: I10d3e8ff8ba0c10a43d21d9002d73134cef18651
Diffstat (limited to 'tests')
-rw-r--r--tests/memtest/bandwidth.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/memtest/bandwidth.cpp b/tests/memtest/bandwidth.cpp
index aa02e66a..caccd638 100644
--- a/tests/memtest/bandwidth.cpp
+++ b/tests/memtest/bandwidth.cpp
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <map>
+#include <memory>
#include <vector>
@@ -227,7 +228,8 @@ bool processThreadArgs(int argc, char** argv, option_t options[],
return false;
}
- BandwidthBenchmark *bench = createBandwidthBenchmarkObject(*values);
+ std::unique_ptr<BandwidthBenchmark> bench{
+ createBandwidthBenchmarkObject(*values)};
if (!bench) {
return false;
}
@@ -250,7 +252,6 @@ bool processThreadArgs(int argc, char** argv, option_t options[],
(*values)["size"].int_value = bench->size();
(*values)["num_warm_loops"].int_value = bench->num_warm_loops();
(*values)["num_loops"].int_value = bench->num_loops();
- delete bench;
return true;
}