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 segmentation fault when matching regex string against non-string values #190

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

crocodele
Copy link
Collaborator

Relates to #188.

I'm not very happy about the handling of booleans etc., but I don't think there's a perfect solution to that. If someone has ideas, feel free to suggest. By default, true would be cast to "1" and false to empty string "".

@crocodele crocodele force-pushed the fix/RegexSegmentationFault branch from fd07e8c to 1cbc017 Compare January 3, 2025 22:31
@crocodele crocodele requested review from dawitnida and mk6i January 3, 2025 22:39
} else if (Z_TYPE_P(lh) == IS_FALSE) {
zs_lh = zend_string_init("false", 5, 0);
} else {
zs_lh = zval_get_string(lh);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to call zend_string_init() again as the logic above already covers specific scalar types on line 300?

Copy link
Member

Choose a reason for hiding this comment

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

Or long, double, etc are not handled so it would end up here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Line 300 is within the if for IS_OBJECT, so it covers objects that can be cast to string with __toString().

This else is indeed primarily for longs, doubles etc. that should be possible to cast to strings.

@crocodele crocodele merged commit ad6f53f into main Jan 14, 2025
15 checks passed
@crocodele crocodele deleted the fix/RegexSegmentationFault branch January 14, 2025 08:03
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.

2 participants