Merge branch 'PHP-7.3'

This commit is contained in:
Nikita Popov 2018-11-15 17:17:06 +01:00
commit 8f2f80668e
3 changed files with 23 additions and 4 deletions

View File

@ -570,6 +570,14 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
GC_DEL_FLAGS(p, GC_PROTECTED); \
} while (0)
#define GC_TRY_PROTECT_RECURSION(p) do { \
if (!(GC_FLAGS(p) & GC_IMMUTABLE)) GC_PROTECT_RECURSION(p); \
} while (0)
#define GC_TRY_UNPROTECT_RECURSION(p) do { \
if (!(GC_FLAGS(p) & GC_IMMUTABLE)) GC_UNPROTECT_RECURSION(p); \
} while (0)
#define Z_IS_RECURSIVE(zval) GC_IS_RECURSIVE(Z_COUNTED(zval))
#define Z_PROTECT_RECURSION(zval) GC_PROTECT_RECURSION(Z_COUNTED(zval))
#define Z_UNPROTECT_RECURSION(zval) GC_UNPROTECT_RECURSION(Z_COUNTED(zval))

View File

@ -3075,7 +3075,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons
php_error_docref(NULL, E_WARNING, "Cannot convert recursively referenced values");
return NULL;
}
GC_PROTECT_RECURSION(input);
GC_TRY_PROTECT_RECURSION(input);
output = zend_new_array(zend_hash_num_elements(input));
ZEND_HASH_FOREACH_KEY_VAL(input, idx, key, entry) {
/* convert key */
@ -3120,7 +3120,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons
zend_hash_index_add(output, idx, &entry_tmp);
}
} ZEND_HASH_FOREACH_END();
GC_UNPROTECT_RECURSION(input);
GC_TRY_UNPROTECT_RECURSION(input);
return output;
}
@ -4682,7 +4682,7 @@ MBSTRING_API int php_mb_check_encoding_recursive(HashTable *vars, const zend_str
php_error_docref(NULL, E_WARNING, "Cannot not handle circular references");
return 0;
}
GC_PROTECT_RECURSION(vars);
GC_TRY_PROTECT_RECURSION(vars);
ZEND_HASH_FOREACH_KEY_VAL(vars, idx, key, entry) {
ZVAL_DEREF(entry);
if (key) {
@ -4716,7 +4716,7 @@ MBSTRING_API int php_mb_check_encoding_recursive(HashTable *vars, const zend_str
break;
}
} ZEND_HASH_FOREACH_END();
GC_UNPROTECT_RECURSION(vars);
GC_TRY_UNPROTECT_RECURSION(vars);
mbfl_buffer_converter_delete(convd);
return valid;
}

View File

@ -0,0 +1,11 @@
--TEST--
Bug #77165: mb_check_encoding crashes when argument given an empty array
--FILE--
<?php
var_dump(mb_check_encoding(array()));
var_dump(mb_convert_encoding(array(), 'UTF-8'));
?>
--EXPECT--
bool(true)
array(0) {
}