From 468b5e28133df8ace28be55f7d908ac1cc60c4ad Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 23 Dec 2023 08:23:15 +0100 Subject: [PATCH] Fix use-after-move --- src/Formats/JSONUtils.cpp | 7 ++++--- src/Functions/concat.cpp | 10 +++++----- src/Functions/format.cpp | 10 +++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Formats/JSONUtils.cpp b/src/Formats/JSONUtils.cpp index 7ddfdb6b572..c018a2e12cc 100644 --- a/src/Formats/JSONUtils.cpp +++ b/src/Formats/JSONUtils.cpp @@ -115,13 +115,14 @@ namespace JSONUtils return {loadAtPosition(in, memory, pos), number_of_rows}; } - std::pair fileSegmentationEngineJSONEachRow(ReadBuffer & in, DB::Memory<> & memory, size_t min_bytes, size_t max_rows) + std::pair fileSegmentationEngineJSONEachRow( + ReadBuffer & in, DB::Memory<> & memory, size_t min_bytes, size_t max_rows) { return fileSegmentationEngineJSONEachRowImpl<'{', '}'>(in, memory, min_bytes, 1, max_rows); } - std::pair - fileSegmentationEngineJSONCompactEachRow(ReadBuffer & in, DB::Memory<> & memory, size_t min_bytes, size_t min_rows, size_t max_rows) + std::pair fileSegmentationEngineJSONCompactEachRow( + ReadBuffer & in, DB::Memory<> & memory, size_t min_bytes, size_t min_rows, size_t max_rows) { return fileSegmentationEngineJSONEachRowImpl<'[', ']'>(in, memory, min_bytes, min_rows, max_rows); } diff --git a/src/Functions/concat.cpp b/src/Functions/concat.cpp index 4d7d9ffb56c..b057e7fede5 100644 --- a/src/Functions/concat.cpp +++ b/src/Functions/concat.cpp @@ -145,13 +145,13 @@ private: } write_helper.finalize(); - /// Same as the normal `ColumnString` branch - has_column_string = true; - data[i] = &converted_col_str->getChars(); - offsets[i] = &converted_col_str->getOffsets(); - /// Keep the pointer alive converted_col_ptrs[i] = std::move(converted_col_str); + + /// Same as the normal `ColumnString` branch + has_column_string = true; + data[i] = &converted_col_ptrs[i]->getChars(); + offsets[i] = &converted_col_ptrs[i]->getOffsets(); } } diff --git a/src/Functions/format.cpp b/src/Functions/format.cpp index f1f73cfe438..41b6d65023b 100644 --- a/src/Functions/format.cpp +++ b/src/Functions/format.cpp @@ -108,13 +108,13 @@ public: } write_helper.finalize(); - /// Same as the normal `ColumnString` branch - has_column_string = true; - data[i - 1] = &converted_col_str->getChars(); - offsets[i - 1] = &converted_col_str->getOffsets(); - /// Keep the pointer alive converted_col_ptrs[i - 1] = std::move(converted_col_str); + + /// Same as the normal `ColumnString` branch + has_column_string = true; + data[i - 1] = &converted_col_ptrs[i - 1]->getChars(); + offsets[i - 1] = &converted_col_ptrs[i - 1]->getOffsets(); } }