From a48382399d7682f7e1d10dd5b3f9c91f7c526f7a Mon Sep 17 00:00:00 2001 From: Nathan Bronson Date: Thu, 17 Dec 2015 12:22:36 -0800 Subject: [PATCH] Fix use-after free in db_bench Test Plan: valgrind db_bench Reviewers: igor, sdong Reviewed By: sdong Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D52101 --- db/db_bench.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/db_bench.cc b/db/db_bench.cc index a7025ca3e..48918b854 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -1633,9 +1633,8 @@ class Benchmark { #endif } - const char* compression = - CompressionTypeToString(FLAGS_compression_type_e).c_str(); - fprintf(stdout, "Compression: %s\n", compression); + auto compression = CompressionTypeToString(FLAGS_compression_type_e); + fprintf(stdout, "Compression: %s\n", compression.c_str()); switch (FLAGS_rep_factory) { case kPrefixHash: @@ -1656,7 +1655,7 @@ class Benchmark { } fprintf(stdout, "Perf Level: %d\n", FLAGS_perf_level); - PrintWarnings(compression); + PrintWarnings(compression.c_str()); fprintf(stdout, "------------------------------------------------\n"); }