Skip to content

Commit 7ebc71d

Browse files
committed
address comments
1 parent 66d8be6 commit 7ebc71d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/logger.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ std::string timestamp(const char* format) {
7777
// Thread-local per-second UTC timestamp cache.
7878
struct TimeCache {
7979
time_t second = 0;
80-
char buf[32];
80+
char buf[64];
8181
size_t len = 0;
8282
};
8383
thread_local TimeCache cache;
@@ -98,7 +98,10 @@ std::string timestamp(const char* format) {
9898

9999
cache.len = ::strftime(cache.buf, sizeof(cache.buf), format, &tmBuf);
100100
cache.second = currentTime;
101-
101+
if (cache.len == 0) {
102+
// Formatting failure fallback.
103+
return "";
104+
}
102105
return std::string(cache.buf, cache.len);
103106
}
104107

0 commit comments

Comments
 (0)