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

fix: ignore whitespace in TryParse #1536

Merged
merged 1 commit into from
Apr 8, 2024
Merged

fix: ignore whitespace in TryParse #1536

merged 1 commit into from
Apr 8, 2024

Conversation

EmosewaMC
Copy link
Collaborator

tested that Not the Boss of Me progresses normally (its cdclient entry is 7805,11225,11226, 11217, 11220, 11214, 11982, 11987, 11989, 12005, 11999, 12467, 12468, 12469, 12591, 12600, 12609, 14381,16047,16048,16049,16050

@aronwk-aaron aronwk-aaron merged commit 3260a06 into main Apr 8, 2024
4 checks passed
@jadebenn
Copy link
Collaborator

jadebenn commented Apr 9, 2024

Is there any possibility here that this could overrun the string_view .size()? I think you'd need a pretty choice confluence of circumstances (string made of whitespace, no null termination, following byte matching a whitespace character), but I think it's possible to invoke UB. Would it make sense to add a length check to the loop?

@EmosewaMC
Copy link
Collaborator Author

EmosewaMC commented Apr 9, 2024

Is there any possibility here that this could overrun the string_view .size()? I think you'd need a pretty choice confluence of circumstances (string made of whitespace, no null termination, following byte matching a whitespace character), but I think it's possible to invoke UB. Would it make sense to add a length check to the loop?

.empty already does this check and .front will throw before allowing ub.

@EmosewaMC EmosewaMC deleted the try-parse branch April 9, 2024 02:42
@EmosewaMC
Copy link
Collaborator Author

I can see how this may overrun (it wont because null termination would result in false and just return). Feel free to make a patch with a working check.

@EmosewaMC
Copy link
Collaborator Author

Is there any possibility here that this could overrun the string_view .size()? I think you'd need a pretty choice confluence of circumstances (string made of whitespace, no null termination, following byte matching a whitespace character), but I think it's possible to invoke UB. Would it make sense to add a length check to the loop?

.empty already does this check and .front will throw before allowing ub.

correction, front does not throw, which is very different from the behavior I had thought front did. not sure where I got that information from.

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.

4 participants