Merge branch 'PHP-8.0'

* PHP-8.0:
  Fix use after free on compound division by zero
This commit is contained in:
Nikita Popov 2021-07-07 09:38:57 +02:00
commit ce3846cd87
2 changed files with 22 additions and 6 deletions

View file

@ -1358,7 +1358,7 @@ ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *o
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_DIV);
zval op1_copy, op2_copy;
zval result_copy, op1_copy, op2_copy;
if (UNEXPECTED(zendi_try_convert_scalar_to_number(op1, &op1_copy) == FAILURE)
|| UNEXPECTED(zendi_try_convert_scalar_to_number(op2, &op2_copy) == FAILURE)) {
zend_binop_error("/", op1, op2);
@ -1368,12 +1368,12 @@ ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *o
return FAILURE;
}
if (result == op1) {
zval_ptr_dtor(result);
}
retval = div_function_base(result, &op1_copy, &op2_copy);
retval = div_function_base(&result_copy, &op1_copy, &op2_copy);
if (retval == SUCCESS) {
if (result == op1) {
zval_ptr_dtor(result);
}
ZVAL_COPY_VALUE(result, &result_copy);
return SUCCESS;
}