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

vis-menu.c: add space for terminating NUL byte #1135

Merged
merged 1 commit into from
Sep 26, 2023
Merged

Conversation

tosch42
Copy link
Contributor

@tosch42 tosch42 commented Sep 25, 2023

No description provided.

@mcepl
Copy link
Contributor

mcepl commented Sep 26, 2023

Hmm, isn’t it cutting off the last character of text?

@rnpnr
Copy link
Collaborator

rnpnr commented Sep 26, 2023

Thanks for the patch Tom! I will apply it now.

vis-menu inherited a lot of rough code from slmenu and it really needs
a rework. This certainly fixes one issue.

Hmm, isn’t it cutting off the last character of text?

No, the sizeof operator in C has no knowledge of the contents of the
buffer text. It simply returns the amount of static memory allocated
for it. If sel->text is as long or longer than sizeof(text) then
the string copied into text will not be terminated by NUL (aka \0,
aka 0). text is memset() to \0 at the start of this loop.

Hope this helps!

@rnpnr rnpnr merged commit b63aa00 into martanne:master Sep 26, 2023
24 checks passed
@tosch42
Copy link
Contributor Author

tosch42 commented Sep 26, 2023

Thanks Randy. I currently have some time which allows me to look deeper into vis-menu. If I come up with a rewrite or some ideas, I'll let you know.

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.

3 participants