mirror of
https://github.com/php/php-src.git
synced 2026-04-23 16:08:35 +02:00
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79149: SEGV in mb_convert_encoding with non-string encodings
This commit is contained in:
@@ -2879,12 +2879,12 @@ PHP_FUNCTION(mb_convert_encoding)
|
||||
|
||||
if ( _from_encodings) {
|
||||
l = strlen(_from_encodings);
|
||||
n = strlen(Z_STRVAL_P(hash_entry));
|
||||
n = strlen(ZSTR_VAL(encoding_str));
|
||||
_from_encodings = erealloc(_from_encodings, l+n+2);
|
||||
memcpy(_from_encodings + l, ",", 1);
|
||||
memcpy(_from_encodings + l + 1, Z_STRVAL_P(hash_entry), Z_STRLEN_P(hash_entry) + 1);
|
||||
memcpy(_from_encodings + l + 1, ZSTR_VAL(encoding_str), ZSTR_LEN(encoding_str) + 1);
|
||||
} else {
|
||||
_from_encodings = estrdup(Z_STRVAL_P(hash_entry));
|
||||
_from_encodings = estrdup(ZSTR_VAL(encoding_str));
|
||||
}
|
||||
zend_string_release(encoding_str);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug #79149 (SEGV in mb_convert_encoding with non-string encodings)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(mb_convert_encoding("", "UTF-8", [0]));
|
||||
var_dump(mb_convert_encoding('foo', 'UTF-8', array(['bar'], ['baz'])));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: mb_convert_encoding(): Illegal character encoding specified in %s on line %d
|
||||
string(0) ""
|
||||
|
||||
Notice: Array to string conversion in %s on line %d
|
||||
|
||||
Notice: Array to string conversion in %s on line %d
|
||||
|
||||
Warning: mb_convert_encoding(): Illegal character encoding specified in %s on line %d
|
||||
string(3) "foo"
|
||||
Reference in New Issue
Block a user