Skip to content

Commit 02a9228

Browse files
committed
Added null case to gmp_zval_binary_ui_op
1 parent 55b553c commit 02a9228

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/gmp/gmp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,22 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *
707707
mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result;
708708
gmp_temp_t temp_a, temp_b;
709709

710+
if (UNEXPECTED(is_operator && Z_TYPE_P(a_arg) == IS_NULL)) {
711+
zval a_arg_2;
712+
ZVAL_LONG(&a_arg_2, 0);
713+
a_arg = &a_arg_2;
714+
}
710715
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a, is_operator ? 0 : 1);
711716

712717
if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) {
713718
gmpnum_b = NULL;
714719
temp_b.is_used = 0;
715720
} else {
721+
if (UNEXPECTED(is_operator && Z_TYPE_P(b_arg) == IS_NULL)) {
722+
zval b_arg_2;
723+
ZVAL_LONG(&b_arg_2, 0);
724+
b_arg = &b_arg_2;
725+
}
716726
FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a, is_operator ? 0 : 2);
717727
}
718728

0 commit comments

Comments
 (0)