Skip to content

Fix GH-12457: Fixed a bug in zend_memnistr #12458

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

Closed
wants to merge 1 commit into from

Conversation

SakiTakamachi
Copy link
Member

@SakiTakamachi SakiTakamachi commented Oct 17, 2023

Closes #12457

(edit) Thanks for the review request, Tim.

@SakiTakamachi
Copy link
Member Author

@iluuu1994
May I request your review?

@SakiTakamachi SakiTakamachi force-pushed the fix/gh-12457 branch 3 times, most recently from 0b168a9 to 9aebcd9 Compare October 17, 2023 14:16
add test phpGH-12457

add test pattern phpGH-12457

Fix order of elvis of zend_memnistr

add more test cases for Fix phpGH-12457

Fixed test expectations for phpGH-12457
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you for catching this @SakiTakamachi!

@@ -945,7 +945,7 @@ zend_memnistr(const char *haystack, const char *needle, size_t needle_len, const
const char *p_upper = NULL;
if (first_lower != first_upper) {
// If the needle length is 1 we don't need to look beyond p_lower as it is a guaranteed match
size_t upper_search_length = end - (needle_len == 1 && p_lower != NULL ? p_lower : haystack);
size_t upper_search_length = needle_len == 1 && p_lower != NULL ? p_lower - haystack : end - haystack;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the original code was meant to be this:

		size_t upper_search_length = (needle_len == 1 && p_lower != NULL ? p_lower : end) - haystack;

But your version may be more readable.

@iluuu1994 iluuu1994 closed this in 736032f Oct 18, 2023
@SakiTakamachi
Copy link
Member Author

Thank you for merge!

@SakiTakamachi SakiTakamachi deleted the fix/gh-12457 branch November 21, 2023 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants