Merge pull request #3929 from YosysHQ/gatecat/fmt-fix

fmt: Fix C++ string assertion when buf is empty
This commit is contained in:
Martin Povišer 2023-09-12 19:44:17 +02:00 committed by GitHub
commit 05f0262d77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}