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

ext/gmp: Fixed Aborted #15660

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ext/gmp/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,22 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *
mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result;
gmp_temp_t temp_a, temp_b;

zval a_arg_2;
if (UNEXPECTED(is_operator && Z_TYPE_P(a_arg) == IS_NULL)) {
ZVAL_LONG(&a_arg_2, 0);
a_arg = &a_arg_2;
}
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a, is_operator ? 0 : 1);

if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) {
gmpnum_b = NULL;
temp_b.is_used = 0;
} else {
zval b_arg_2;
if (UNEXPECTED(is_operator && Z_TYPE_P(b_arg) == IS_NULL)) {
ZVAL_LONG(&b_arg_2, 0);
b_arg = &b_arg_2;
}
FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a, is_operator ? 0 : 2);
}

Expand Down
5 changes: 5 additions & 0 deletions ext/gmp/tests/overloading.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $b = gmp_init(17);
var_dump($a + $b);
var_dump($a + 17);
var_dump(42 + $b);
var_dump($a + null);

var_dump($a - $b);
var_dump($a - 17);
Expand Down Expand Up @@ -136,6 +137,10 @@ object(GMP)#3 (1) {
["num"]=>
string(2) "59"
}
object(GMP)#3 (1) {
["num"]=>
string(2) "42"
}
object(GMP)#3 (1) {
["num"]=>
string(2) "25"
Expand Down
Loading