Skip to content

Commit 1032018

Browse files
authored
Fixed issue gabime#3360 (gabime#3361)
1 parent 3335c38 commit 1032018

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

include/spdlog/pattern_formatter-inl.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class scoped_padder {
7070
pad_it(remaining_pad_);
7171
} else if (padinfo_.truncate_) {
7272
long new_size = static_cast<long>(dest_.size()) + remaining_pad_;
73+
if (new_size < 0) {
74+
new_size = 0;
75+
}
7376
dest_.resize(static_cast<size_t>(new_size));
7477
}
7578
}
@@ -264,7 +267,7 @@ class D_formatter final : public flag_formatter {
264267
: flag_formatter(padinfo) {}
265268

266269
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
267-
const size_t field_size = 10;
270+
const size_t field_size = 8;
268271
ScopedPadder p(field_size, padinfo_, dest);
269272

270273
fmt_helper::pad2(tm_time.tm_mon + 1, dest);
@@ -926,9 +929,8 @@ class full_formatter final : public flag_formatter {
926929
memory_buf_t cached_datetime_;
927930

928931
#ifndef SPDLOG_NO_TLS
929-
mdc_formatter<null_scoped_padder> mdc_formatter_{padding_info{}};
932+
mdc_formatter<null_scoped_padder> mdc_formatter_{padding_info {}};
930933
#endif
931-
932934
};
933935

934936
} // namespace details

0 commit comments

Comments
 (0)