diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 2e84e8eb4..9be1bcbc3 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -1805,7 +1805,7 @@ class StressTest { thread->rand.Uniform(FLAGS_backup_one_in) == 0) { std::string backup_dir = FLAGS_db + "/.backup" + ToString(thread->tid); BackupableDBOptions backup_opts(backup_dir); - BackupEngine* backup_engine; + BackupEngine* backup_engine = nullptr; Status s = BackupEngine::Open(FLAGS_env, backup_opts, &backup_engine); if (s.ok()) { s = backup_engine->CreateNewBackup(db_); @@ -1817,6 +1817,9 @@ class StressTest { printf("A BackupEngine operation failed with: %s\n", s.ToString().c_str()); } + if (backup_engine != nullptr) { + delete backup_engine; + } } if (FLAGS_compact_files_one_in > 0 &&