replay: fix potential timestamp parsing error in Route::load (#35117)

Fix potential timestamp parsing error in Route::load
This commit is contained in:
Dean Lee
2025-05-05 01:15:25 +08:00
committed by GitHub
parent db6832762b
commit 8c8b2c4488
2 changed files with 5 additions and 3 deletions

View File

@@ -50,9 +50,11 @@ bool Route::load() {
return false;
}
// Parse the timestamp from the route identifier (only applicable for old route formats).
struct tm tm_time = {0};
strptime(route_.timestamp.c_str(), "%Y-%m-%d--%H-%M-%S", &tm_time);
date_time_ = mktime(&tm_time);
if (strptime(route_.timestamp.c_str(), "%Y-%m-%d--%H-%M-%S", &tm_time)) {
date_time_ = mktime(&tm_time);
}
bool ret = data_dir_.empty() ? loadFromServer() : loadFromLocal();
if (ret) {

View File

@@ -59,7 +59,7 @@ protected:
RouteIdentifier route_ = {};
std::string data_dir_;
std::map<int, SegmentFile> segments_;
std::time_t date_time_;
std::time_t date_time_ = 0;
RouteLoadError err_ = RouteLoadError::None;
};