Skip to content

Commit a7c6402

Browse files
committed
Moved null check in do_operation to bcmath_number_parse_num
1 parent d7483f8 commit a7c6402

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

ext/bcmath/bcmath.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,10 @@ static zend_result bcmath_number_parse_num(zval *zv, zend_object **obj, zend_str
11121112
*str = Z_STR_P(zv);
11131113
return SUCCESS;
11141114

1115+
case IS_NULL:
1116+
*lval = 0;
1117+
return SUCCESS;
1118+
11151119
default:
11161120
return zend_parse_arg_str_or_long_slow(zv, str, lval, 1 /* dummy */) ? SUCCESS : FAILURE;
11171121
}
@@ -1176,15 +1180,7 @@ static zend_result bcmath_number_do_operation(uint8_t opcode, zval *ret_val, zva
11761180
zend_string *str2 = NULL;
11771181
zend_long lval2;
11781182

1179-
if (UNEXPECTED(Z_TYPE_P(op1) == IS_NULL)) {
1180-
lval1 = 0;
1181-
} else if (UNEXPECTED(bcmath_number_parse_num(op1, &obj1, &str1, &lval1) == FAILURE)) {
1182-
return FAILURE;
1183-
}
1184-
1185-
if (UNEXPECTED(Z_TYPE_P(op2) == IS_NULL)) {
1186-
lval2 = 0;
1187-
} else if (UNEXPECTED(bcmath_number_parse_num(op2, &obj2, &str2, &lval2) == FAILURE)) {
1183+
if (UNEXPECTED(bcmath_number_parse_num(op1, &obj1, &str1, &lval1) == FAILURE || bcmath_number_parse_num(op2, &obj2, &str2, &lval2) == FAILURE)) {
11881184
return FAILURE;
11891185
}
11901186

0 commit comments

Comments
 (0)