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

[ft_substr] false positive? #19

Closed
mjy9088 opened this issue Apr 3, 2022 · 2 comments
Closed

[ft_substr] false positive? #19

mjy9088 opened this issue Apr 3, 2022 · 2 comments

Comments

@mjy9088
Copy link

mjy9088 commented Apr 3, 2022

s = ft_substr("tripouille", 100, 1);
/* 5 */ check(!strcmp(s, ""));
/* 6 */ mcheck(s, 1); free(s); showLeaks();

This test might be problematic

ft_substr("123456789\0Hello world!", 10, 100); // "Hello world!" expected? or undefined behavior?
@Tripouille
Copy link
Owner

imo if start >= len(s) an empty string allocated should be return.

@mjy9088
Copy link
Author

mjy9088 commented Apr 9, 2022

May I ask why wouldn't that be considered invalid input?

There is a mention of the case where length is longer than the remaining length, but no mention of the case where start is longer than the total length.

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

No branches or pull requests

2 participants