Skip to content

Commit 3fef47d

Browse files
committed
Added null case to gmp_zval_binary_ui_op
1 parent 55b553c commit 3fef47d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ext/gmp/gmp.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,21 @@ 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-
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a, is_operator ? 0 : 1);
710+
if (UNEXPECTED(is_operator && Z_TYPE_P(a_arg) == IS_NULL)) {
711+
mpz_set_si(gmpnum_a, 0);
712+
} else {
713+
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a, is_operator ? 0 : 1);
714+
}
711715

712716
if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) {
713717
gmpnum_b = NULL;
714718
temp_b.is_used = 0;
715719
} else {
716-
FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a, is_operator ? 0 : 2);
720+
if (UNEXPECTED(is_operator && Z_TYPE_P(b_arg) == IS_NULL)) {
721+
mpz_set_si(gmpnum_b, 0);
722+
} else {
723+
FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a, is_operator ? 0 : 2);
724+
}
717725
}
718726

719727
if (check_b_zero) {

0 commit comments

Comments
 (0)