fmt: Fix C++ string assertion when buf is empty

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2023-09-12 18:12:07 +02:00
parent 88ce47e4f0
commit 98b9459535
1 changed files with 1 additions and 1 deletions

View File

@ -740,7 +740,7 @@ std::string Fmt::render() const
log_assert(part.width == 0 || part.padding != '\0');
if (part.justify == FmtPart::RIGHT && buf.size() < part.width) {
size_t pad_width = part.width - buf.size();
if (part.padding == '0' && (buf.front() == '+' || buf.front() == '-')) {
if (part.padding == '0' && (!buf.empty() && (buf.front() == '+' || buf.front() == '-'))) {
str += buf.front();
buf.erase(0, 1);
}