From fa2dc5aefa5c4e61dfcd70975fa17a125bc59297 Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Tue, 23 Apr 2024 05:23:20 -0300 Subject: [PATCH] sstables: Fix use-after-move in an error path of FS-based sstable writer ``` sstables/storage.cc:152:21: warning: 'file_path' used after it was moved [bugprone-use-after-move] remove_file(file_path).get(); ^ sstables/storage.cc:145:64: note: move occurred here auto w = file_writer(output_stream(std::move(sink)), std::move(file_path)); ``` It's a regression when TOC is found for a new sstable, and we try to delete temporary TOC. courtesy of clang-tidy. Fixes #18323. Signed-off-by: Raphael S. Carvalho Closes scylladb/scylladb#18367 --- sstables/storage.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sstables/storage.cc b/sstables/storage.cc index 23d4fea3c4..cecff9ebfe 100644 --- a/sstables/storage.cc +++ b/sstables/storage.cc @@ -151,7 +151,7 @@ void filesystem_storage::open(sstable& sst) { // TOC will exist at this point if write_components() was called with // the generation of a sstable that exists. w.close(); - remove_file(file_path).get(); + remove_file(sst.filename(component_type::TemporaryTOC)).get(); throw std::runtime_error(format("SSTable write failed due to existence of TOC file for generation {} of {}.{}", sst._generation, sst._schema->ks_name(), sst._schema->cf_name())); }