Skip to content

Commit 4b2d9ff

Browse files
committed
ext/gmp: Add weak mode support for parsing
1 parent 636e0ed commit 4b2d9ff

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ext/gmp/gmp.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ static bool gmp_zend_parse_arg_into_mpz_ex(
188188
mpz_set_si(*destination_mpz_ptr, Z_LVAL_P(arg));
189189
return true;
190190
}
191+
192+
/* This function is also used by the do_operation object hook,
193+
* but operator overloading with objects should behave as if a
194+
* method was called, thus strict types should apply. */
195+
if (!ZEND_ARG_USES_STRICT_TYPES()) {
196+
zend_long lval = 0;
197+
if (is_operator && Z_TYPE_P(arg) == IS_NULL) {
198+
return false;
199+
}
200+
if (!zend_parse_arg_long_weak(arg, &lval, arg_num)) {
201+
return false;
202+
}
203+
204+
mpz_set_si(*destination_mpz_ptr, lval);
205+
206+
return true;
207+
}
208+
191209
return false;
192210
}
193211

0 commit comments

Comments
 (0)