Skip to content

Commit

Permalink
Merge pull request #3929 from YosysHQ/gatecat/fmt-fix
Browse files Browse the repository at this point in the history
fmt: Fix C++ string assertion when buf is empty
  • Loading branch information
povik authored Sep 12, 2023
2 parents b04f235 + 98b9459 commit 05f0262
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 05f0262

Please sign in to comment.