mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
fmt: Fix C++ string assertion when buf is empty
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
parent
88ce47e4f0
commit
98b9459535
|
@ -740,7 +740,7 @@ std::string Fmt::render() const
|
||||||
log_assert(part.width == 0 || part.padding != '\0');
|
log_assert(part.width == 0 || part.padding != '\0');
|
||||||
if (part.justify == FmtPart::RIGHT && buf.size() < part.width) {
|
if (part.justify == FmtPart::RIGHT && buf.size() < part.width) {
|
||||||
size_t pad_width = part.width - buf.size();
|
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();
|
str += buf.front();
|
||||||
buf.erase(0, 1);
|
buf.erase(0, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue