Skip to content

Commit 0831608

Browse files
committed
ext/gmp: Add weak mode support for parsing
1 parent 2704410 commit 0831608

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
@@ -192,6 +192,24 @@ static bool gmp_zend_parse_arg_into_mpz_ex(
192192
mpz_set_si(*destination_mpz_ptr, Z_LVAL_P(arg));
193193
return true;
194194
}
195+
196+
/* This function is also used by the do_operation object hook,
197+
* but operator overloading with objects should behave as if a
198+
* method was called, thus strict types should apply. */
199+
if (!ZEND_ARG_USES_STRICT_TYPES()) {
200+
zend_long lval = 0;
201+
if (is_operator && Z_TYPE_P(arg) == IS_NULL) {
202+
return false;
203+
}
204+
if (!zend_parse_arg_long_weak(arg, &lval, arg_num)) {
205+
return false;
206+
}
207+
208+
mpz_set_si(*destination_mpz_ptr, lval);
209+
210+
return true;
211+
}
212+
195213
return false;
196214
}
197215

0 commit comments

Comments
 (0)