Skip to content

ext/bcmath: null should not be supported for operator overloading + comparison issues #15875

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

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Sep 13, 2024

@SakiTakamachi you have memory leaks with the handling of the comparison operators and some conversions to string which don't make much sense to me (namely array to string).

@SakiTakamachi
Copy link
Member

@Girgias
Thanks for catching this!

@SakiTakamachi
Copy link
Member

I forgot to do this on failure.

if (Z_TYPE_P(op1) != IS_OBJECT) {
	bc_free_num(&n1);
}

if (Z_TYPE_P(op2) != IS_OBJECT) {
	bc_free_num(&n2);
}

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

This is fine, I have one minor remark/nit

@@ -1280,8 +1283,15 @@ static int bcmath_number_compare(zval *op1, zval *op2)

return (int) ret;

fallback:
return zend_std_compare_objects(op1, op2);
failure:
Copy link
Member

Choose a reason for hiding this comment

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

If you declare int ret = ZEND_UNCOMPARABLE; at the start of the function, then you can put the failure label at line 1276, which would reduce code duplication.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, sorry for the delay

Copy link
Member

@SakiTakamachi SakiTakamachi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

edit:
Please correct only the points mentioned by Niels :)

@Girgias
Copy link
Member Author

Girgias commented Sep 20, 2024

CI is failing because of cURL tests and a failure to set up MySQL

@Girgias Girgias force-pushed the bcmath-null-operator-overloading branch from da4d6af to 373c7d1 Compare September 23, 2024 09:32
@Girgias Girgias merged commit 585cf9c into php:master Sep 23, 2024
8 of 10 checks passed
@Girgias Girgias deleted the bcmath-null-operator-overloading branch September 23, 2024 10:49
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.

3 participants