com php-src: Merge branch 'PHP-7.1': Zend/zend_operators.c

[email protected] (Xinchen Hui)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    963981df5898ceb2626d454e2825270c4c977718
Author:    Xinchen Hui <[email protected]>         Sun, 12 Feb 2017 20:36:43 +0800
Parents:   fb22a0f48ddce9950094b309ac6fb49928730863 b96c5b14b9d0ee6f90bdb7d1c0815b7f6b5109cd
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=963981df5898ceb2626d454e2825270c4c977718

Log:
Merge branch 'PHP-7.1'

* PHP-7.1:
  Update NEWS
  Fixed bug #74084 (Out of bound read - zend_mm_alloc_small)

Bugs:
https://bugs.php.net/74084

Changed paths:
  MM  Zend/zend_operators.c


Diff:
diff --cc Zend/zend_operators.c
index fd15e8e,418d2f0..37fa5e9
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@@ -941,13 -951,15 +941,18 @@@ ZEND_API int ZEND_FASTCALL add_function
  				} else if (!converted) {
  					ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_ADD, add_function);
  
- 					zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
- 					zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					if (EXPECTED(op1 != op2)) {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					} else {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						op2 = op1;
+ 					}
  					converted = 1;
  				} else {
 +					if (result != op1) {
 +						ZVAL_UNDEF(result);
 +					}
  					zend_throw_error(NULL, "Unsupported operand types");
  					return FAILURE; /* unknown datatype */
  				}
@@@ -986,13 -998,15 +991,18 @@@ ZEND_API int ZEND_FASTCALL sub_function
  				} else if (!converted) {
  					ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SUB, sub_function);
  
- 					zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
- 					zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					if (EXPECTED(op1 != op2)) {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					} else {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						op2 = op1;
+ 					}
  					converted = 1;
  				} else {
 +					if (result != op1) {
 +						ZVAL_UNDEF(result);
 +					}
  					zend_throw_error(NULL, "Unsupported operand types");
  					return FAILURE; /* unknown datatype */
  				}
@@@ -1036,13 -1050,15 +1046,18 @@@ ZEND_API int ZEND_FASTCALL mul_function
  				} else if (!converted) {
  					ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_MUL, mul_function);
  
- 					zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
- 					zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					if (EXPECTED(op1 != op2)) {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					} else {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						op2 = op1;
+ 					}
  					converted = 1;
  				} else {
 +					if (result != op1) {
 +						ZVAL_UNDEF(result);
 +					}
  					zend_throw_error(NULL, "Unsupported operand types");
  					return FAILURE; /* unknown datatype */
  				}
@@@ -1195,13 -1218,15 +1220,18 @@@ ZEND_API int ZEND_FASTCALL div_function
  				} else if (!converted) {
  					ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_DIV, div_function);
  
- 					zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
- 					zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					if (EXPECTED(op1 != op2)) {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						zendi_convert_scalar_to_number(op2, op2_copy, result, 0);
+ 					} else {
+ 						zendi_convert_scalar_to_number(op1, op1_copy, result, 0);
+ 						op2 = op1;
+ 					}
  					converted = 1;
  				} else {
 +					if (result != op1) {
 +						ZVAL_UNDEF(result);
 +					}
  					zend_throw_error(NULL, "Unsupported operand types");
  					return FAILURE; /* unknown datatype */
  				}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.