Skip to content

Commit ba4109e

Browse files
committed
Reviews
1 parent c2a0b78 commit ba4109e

File tree

9 files changed

+13
-15
lines changed

9 files changed

+13
-15
lines changed

ext/bcmath/bcmath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ PHP_FUNCTION(bcsqrt)
473473
if (bc_sqrt (&result, scale) != 0) {
474474
RETVAL_STR(bc_num2str_ex(result, scale));
475475
} else {
476-
zend_argument_value_error(1, "cannot take square root of a negative number");
476+
zend_argument_value_error(1, "must be greater than or equal to 0");
477477
}
478478

479479
bc_free_num(&result);

ext/bcmath/libbcmath/src/init.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ _bc_new_num_ex (length, scale, persistent)
4444
int length, scale, persistent;
4545
{
4646
bc_num temp;
47-
/* PHP Change: add length check */
48-
if ((size_t)length + (size_t)scale > INT_MAX) {
49-
zend_throw_error(NULL, "Result exceeds the length a PHP string can hold");
50-
}
5147
/* PHP Change: malloc() -> pemalloc(), removed free_list code */
5248
temp = (bc_num) safe_pemalloc (1, sizeof(bc_struct)+length, scale, persistent);
5349
temp->n_sign = PLUS;

ext/bcmath/libbcmath/src/raise.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale)
5555
/* Check the exponent for scale digits and convert to a long. */
5656
if (num2->n_scale != 0) {
5757
/* 2nd argument from PHP_FUNCTION(bcpow) */
58-
zend_argument_value_error(2, "must be an integer");
58+
zend_argument_value_error(2, "cannot have a fractional part");
59+
return;
5960
}
6061
exponent = bc_num2long (num2);
6162
if (exponent == 0 && (num2->n_len > 1 || num2->n_value[0] != 0)) {
6263
/* 2nd argument from PHP_FUNCTION(bcpow) */
6364
zend_argument_value_error(2, "is too large");
65+
return;
6466
}
6567

6668
/* Special case if exponent is a zero. */

ext/bcmath/libbcmath/src/raisemod.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ zend_result bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, i
4747
/* Check the base for scale digits. */
4848
if (base->n_scale != 0) {
4949
/* 1st argument from PHP_FUNCTION(bcpowmod) */
50-
zend_argument_value_error(1, "must be an integer");
50+
zend_argument_value_error(1, "cannot have a fractional part");
5151
return FAILURE;
5252
}
5353
/* Check the exponent for scale digits. */
5454
if (expo->n_scale != 0) {
5555
/* 2nd argument from PHP_FUNCTION(bcpowmod) */
56-
zend_argument_value_error(2, "must be an integer");
56+
zend_argument_value_error(2, "cannot have a fractional part");
5757
return FAILURE;
5858
}
5959
if (bc_is_neg(expo)) {
@@ -63,7 +63,7 @@ zend_result bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, i
6363
/* Check the modulus for scale digits. */
6464
if (mod->n_scale != 0) {
6565
/* 3rd argument from PHP_FUNCTION(bcpowmod) */
66-
zend_argument_value_error(3, "must be an integer");
66+
zend_argument_value_error(3, "cannot have a fractional part");
6767
return FAILURE;
6868
}
6969
/* Modulus cannot be 0 */

ext/bcmath/tests/bcpow_error1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ try {
1313
}
1414
?>
1515
--EXPECT--
16-
bcpow(): Argument #2 ($exponent) must be an integer
16+
bcpow(): Argument #2 ($exponent) cannot have a fractional part

ext/bcmath/tests/bcsqrt_error1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ try {
1414
}
1515
?>
1616
--EXPECT--
17-
bcsqrt(): Argument #1 ($operand) cannot take square root of a negative number
17+
bcsqrt(): Argument #1 ($operand) must be greater than or equal to 0

ext/bcmath/tests/bug72093.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ try {
1919
?>
2020
--EXPECT--
2121
bcpowmod(): Argument #4 ($scale) must be between 0 and 2147483647
22-
bcpowmod(): Argument #2 ($exponent) must be an integer
22+
bcpowmod(): Argument #2 ($exponent) cannot have a fractional part

ext/bcmath/tests/bug75178.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ try {
1818
}
1919
?>
2020
--EXPECT--
21-
bcpowmod(): Argument #1 ($base) must be an integer
22-
bcpowmod(): Argument #3 ($modulus) must be an integer
21+
bcpowmod(): Argument #1 ($base) cannot have a fractional part
22+
bcpowmod(): Argument #3 ($modulus) cannot have a fractional part

ext/bcmath/tests/bug78878.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ try {
1313
}
1414
?>
1515
--EXPECT--
16-
bcpowmod(): Argument #3 ($modulus) must be an integer
16+
bcpowmod(): Argument #3 ($modulus) cannot have a fractional part

0 commit comments

Comments
 (0)