mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix use-after-free
This commit is contained in:
parent
6b34398e9c
commit
37de54937c
@ -407,14 +407,20 @@ try
|
|||||||
}
|
}
|
||||||
|
|
||||||
StreamingFormatExecutor executor(header, format, std::move(on_error), std::move(adding_defaults_transform));
|
StreamingFormatExecutor executor(header, format, std::move(on_error), std::move(adding_defaults_transform));
|
||||||
std::unique_ptr<ReadBuffer> buffer;
|
std::unique_ptr<ReadBuffer> last_buffer;
|
||||||
for (const auto & entry : data->entries)
|
for (const auto & entry : data->entries)
|
||||||
{
|
{
|
||||||
buffer = std::make_unique<ReadBufferFromString>(entry->bytes);
|
auto buffer = std::make_unique<ReadBufferFromString>(entry->bytes);
|
||||||
current_entry = entry;
|
current_entry = entry;
|
||||||
total_rows += executor.execute(*buffer);
|
total_rows += executor.execute(*buffer);
|
||||||
|
|
||||||
|
/// Keep buffer, because it still can be used
|
||||||
|
/// in destructor, while resetting buffer at next iteration.
|
||||||
|
last_buffer = std::move(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
format->addBuffer(std::move(last_buffer));
|
||||||
|
|
||||||
auto chunk = Chunk(executor.getResultColumns(), total_rows);
|
auto chunk = Chunk(executor.getResultColumns(), total_rows);
|
||||||
size_t total_bytes = chunk.bytes();
|
size_t total_bytes = chunk.bytes();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user