From 98b485d3bb93043ec6587c89be2933c32d180015 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 17:43:31 +0000 Subject: [PATCH 1/2] Initial plan From 762fefce72fc1f3a72a4085c2674f8d22fed5238 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 17:45:54 +0000 Subject: [PATCH 2/2] Replace non-reentrant localtime with localtime_r, zero-init struct tm, check return value Agent-Logs-Url: https://github.com/mccaffers/backtesting-engine-cpp/sessions/b4ab18b5-0938-4228-8b14-46cee2a9f7e1 Co-authored-by: mccaffers <16667079+mccaffers@users.noreply.github.com> --- source/databaseConnection.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/databaseConnection.cpp b/source/databaseConnection.cpp index 419f39b..292da31 100644 --- a/source/databaseConnection.cpp +++ b/source/databaseConnection.cpp @@ -61,7 +61,11 @@ void DatabaseConnection::printResults(const std::vector& results) con for (const auto& data : results) { // Convert timestamp back to string for display auto time_t = std::chrono::system_clock::to_time_t(data.timestamp); - auto tm = *std::localtime(&time_t); + struct tm tm = {}; + if (localtime_r(&time_t, &tm) == nullptr) { + std::cerr << "Error: failed to convert timestamp" << std::endl; + continue; + } std::stringstream ss; ss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S");