Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 12, 2023
Merged

Conversation

gatecat
Copy link
Member

@gatecat gatecat commented Sep 12, 2023

Fixes #3923

@@ -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() == '-'))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a nit there seems to be one set of parentheses too many, otherwise LGTM, great to have this fixed

@povik povik merged commit 05f0262 into master Sep 12, 2023
30 checks passed
@mmicko mmicko deleted the gatecat/fmt-fix branch September 12, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

commit 9f8e039a4 causes tests/arch/nexus to segfault on Fedora builds
2 participants