File tree Expand file tree Collapse file tree 3 files changed +41
-5
lines changed Expand file tree Collapse file tree 3 files changed +41
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ PHP NEWS
11
11
. Fixed bug #79078 (Hypothetical use-after-free in curl_multi_add_handle()).
12
12
(cmb)
13
13
14
+ - MBString:
15
+ . Fixed bug #79154 (mb_convert_encoding() can modify $from_encoding). (cmb)
16
+
14
17
- MySQLnd:
15
18
. Fixed bug #79084 (mysqlnd may fetch wrong column indexes with MYSQLI_BOTH).
16
19
(cmb)
Original file line number Diff line number Diff line change @@ -3232,17 +3232,16 @@ PHP_FUNCTION(mb_convert_encoding)
3232
3232
_from_encodings = NULL ;
3233
3233
3234
3234
ZEND_HASH_FOREACH_VAL (target_hash , hash_entry ) {
3235
-
3236
- convert_to_string_ex (hash_entry );
3235
+ zend_string * encoding_str = zval_get_string (hash_entry );
3237
3236
3238
3237
if ( _from_encodings ) {
3239
3238
l = strlen (_from_encodings );
3240
- n = strlen (Z_STRVAL_P ( hash_entry ));
3239
+ n = strlen (ZSTR_VAL ( encoding_str ));
3241
3240
_from_encodings = erealloc (_from_encodings , l + n + 2 );
3242
3241
memcpy (_from_encodings + l , "," , 1 );
3243
- memcpy (_from_encodings + l + 1 , Z_STRVAL_P ( hash_entry ), Z_STRLEN_P ( hash_entry ) + 1 );
3242
+ memcpy (_from_encodings + l + 1 , ZSTR_VAL ( encoding_str ), ZSTR_LEN ( encoding_str ) + 1 );
3244
3243
} else {
3245
- _from_encodings = estrdup (Z_STRVAL_P ( hash_entry ));
3244
+ _from_encodings = estrdup (ZSTR_VAL ( encoding_str ));
3246
3245
}
3247
3246
} ZEND_HASH_FOREACH_END ();
3248
3247
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug 79154 (mb_convert_encoding() can modify $from_encoding)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ('mbstring ' )) die ('mbstring extension not available ' );
6
+ ?>
7
+ --FILE--
8
+ <?php
9
+ class Utf8Encoding
10
+ {
11
+ public function __toString ()
12
+ {
13
+ return 'UTF-8 ' ;
14
+ }
15
+ }
16
+
17
+ $ utf8encoding = new Utf8Encoding ();
18
+ $ encodings = [$ utf8encoding ];
19
+ var_dump ($ encodings );
20
+ mb_convert_encoding ('foo ' , 'UTF-8 ' , $ encodings );
21
+ var_dump ($ encodings );
22
+
23
+ ?>
24
+ --EXPECTF--
25
+ array(1) {
26
+ [0]=>
27
+ object(Utf8Encoding)#%d (0) {
28
+ }
29
+ }
30
+ array(1) {
31
+ [0]=>
32
+ object(Utf8Encoding)#%d (0) {
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments