Skip to content

Fix char buffer not getting terminated when adding new char#3

Open
kittrz9 wants to merge 1 commit into
axollyon:axotextfrom
kittrz9:unterminated_buffer_fix
Open

Fix char buffer not getting terminated when adding new char#3
kittrz9 wants to merge 1 commit into
axollyon:axotextfrom
kittrz9:unterminated_buffer_fix

Conversation

@kittrz9
Copy link
Copy Markdown
Contributor

@kittrz9 kittrz9 commented Mar 21, 2024

If you call axotext_print on one frame and again on the next frame with a string that has more unique chars than the previous string, it ends up drawing random garbage to the screen due to the pointer to the next char at the end never being set to null.

You can replicate this bug with this code, placed in hud.c before axotext_render:

static u8 asdf = 0;
if(asdf++ == 0) {
    axotext_print(160, 40, &params, -1, "aaaaaaaaaaaaaaaaaaa");
} else {
    axotext_print(160, 40, &params, -1, "qwertyuiopasdf!?><@");
}

Without the fix:
2024-03-21_15-04_1

With the fix:
2024-03-21_15-04

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.

1 participant