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

Exit early if we strlen on an empty string #493

Closed
wants to merge 1 commit into from

Conversation

AreaZR
Copy link
Contributor

@AreaZR AreaZR commented May 22, 2024

In the event we do strlen on an empty string, we should bail.

In the event we do strlen on an empty string, we should bail.
Signed-off-by: Rose <[email protected]>
@AreaZR AreaZR changed the title Prevent l from becoming negative if strlen returns 0 Exit early if we strlen on an empty string May 22, 2024
@paulusmack
Copy link
Collaborator

paulusmack commented May 23, 2024

In the context of the existing code, the change proposed is reasonable, but the commit message is not illuminating, because it doesn't explain the connection between an empty string and bailing out. The mention of strlen doesn't help - doing strlen on an empty string is fine.

I think the existing code is actually buggy and has been buggy since it was first written, in that it treats all allowed number strings as wildcards, whether there is a '*' on the end or not. I don't think that was really the original intention. That means that an empty string is equivalent to "*", and that is why bailing out on an empty string is correct (in terms of fixing the code without changing its behaviour).

@Neustradamus
Copy link
Member

@AtariDreams: Have you seen the @paulusmack answer?

@paulusmack
Copy link
Collaborator

never mind... I pushed a change to make it handle non-wildcards correctly, which also solves the issue this PR was addressing.

@paulusmack paulusmack closed this Aug 18, 2024
@AreaZR AreaZR deleted the range-check branch August 18, 2024 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants