From 8c7d7c3e827f1124e04102e159494c35545a6860 Mon Sep 17 00:00:00 2001 From: Tim Stack Date: Tue, 30 Apr 2024 08:58:36 -0700 Subject: [PATCH] [misc] fix a couple of memory issues --- src/line_buffer.cc | 7 +++++-- src/log_format_impls.cc | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/line_buffer.cc b/src/line_buffer.cc index 39edae7e..8d6eafb3 100644 --- a/src/line_buffer.cc +++ b/src/line_buffer.cc @@ -371,6 +371,10 @@ line_buffer::line_buffer() line_buffer::~line_buffer() { + if (this->lb_loader_future.valid()) { + this->lb_loader_future.wait(); + } + auto empty_fd = auto_fd(); // Make sure any shared refs take ownership of the data. @@ -773,8 +777,7 @@ line_buffer::fill_range(file_off_t start, ssize_t max_length) if (this->lb_loader_future.wait_for(std::chrono::seconds(0)) != std::future_status::ready) { - wait_start - = std::make_optional(std::chrono::system_clock::now()); + wait_start = std::make_optional(std::chrono::system_clock::now()); } retval = this->lb_loader_future.get(); if (false && wait_start) { diff --git a/src/log_format_impls.cc b/src/log_format_impls.cc index 8784c11d..85f0f5b3 100644 --- a/src/log_format_impls.cc +++ b/src/log_format_impls.cc @@ -86,11 +86,12 @@ public: shared_buffer_ref& sbr, bool full_message) override { - this->plf_cached_line.resize(23); - sql_strftime(this->plf_cached_line.data(), - this->plf_cached_line.size(), - ll.get_timeval(), - 'T'); + this->plf_cached_line.resize(32); + auto tlen = sql_strftime(this->plf_cached_line.data(), + this->plf_cached_line.size(), + ll.get_timeval(), + 'T'); + this->plf_cached_line.resize(tlen); { char zone_str[16]; exttm tmptm;