Skip to content

Commit 5e99993

Browse files
committed
Fixed autoconversion of negative values to double (Fix bug php#11685)
1 parent eaaf36b commit 5e99993

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Zend/zend_operators.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ ZEND_API int add_function(zval *result, zval *op1, zval *op2)
611611
if (op1->type == IS_LONG && op2->type == IS_LONG) {
612612
double dval = (double) op1->value.lval + (double) op2->value.lval;
613613

614-
if (dval > (double) LONG_MAX) {
614+
if ((dval > (double) LONG_MAX) || (dval < (double) LONG_MIN)) {
615615
result->value.dval = dval;
616616
result->type = IS_DOUBLE;
617617
} else {
@@ -648,7 +648,7 @@ ZEND_API int sub_function(zval *result, zval *op1, zval *op2)
648648
if (op1->type == IS_LONG && op2->type == IS_LONG) {
649649
double dval = (double) op1->value.lval - (double) op2->value.lval;
650650

651-
if (dval < (double) LONG_MIN) {
651+
if ((dval < (double) LONG_MIN) || (dval > (double) LONG_MAX)) {
652652
result->value.dval = dval;
653653
result->type = IS_DOUBLE;
654654
} else {
@@ -685,7 +685,7 @@ ZEND_API int mul_function(zval *result, zval *op1, zval *op2)
685685
if (op1->type == IS_LONG && op2->type == IS_LONG) {
686686
double dval = (double) op1->value.lval * (double) op2->value.lval;
687687

688-
if (dval > (double) LONG_MAX) {
688+
if ((dval > (double) LONG_MAX) || (dval < (double) LONG_MIN)) {
689689
result->value.dval = dval;
690690
result->type = IS_DOUBLE;
691691
} else {

0 commit comments

Comments
 (0)