Skip to content

Commit 18dc904

Browse files
committed
Fix bug 79441
1 parent 33226c3 commit 18dc904

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

ext/mbstring/mbstring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4931,7 +4931,7 @@ static inline zend_string *php_mb_chr(zend_long cp, const char *enc_name)
49314931

49324932
no_enc = enc->no_encoding;
49334933
if (php_mb_is_unsupported_no_encoding(no_enc)) {
4934-
php_error_docref(NULL, E_WARNING, "Unsupported encoding \"%s\"", enc_name);
4934+
php_error_docref(NULL, E_WARNING, "Unsupported encoding \"%s\"", enc->name);
49354935
return NULL;
49364936
}
49374937

ext/mbstring/tests/bug79441.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #79441 Segfault in mb_chr() if internal encoding is unsupported
3+
--SKIPIF--
4+
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5+
--FILE--
6+
<?php
7+
8+
mb_internal_encoding("utf-7");
9+
mb_chr(0xd800);
10+
11+
?>
12+
--EXPECTF--
13+
Warning: mb_chr(): Unsupported encoding "UTF-7" in %s on line %d

ext/mbstring/tests/mb_chr.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ Warning: mb_chr(): Unknown encoding "typo" in %s on line %d
3030

3131
Warning: mb_chr(): Unsupported encoding "pass" in %s on line %d
3232

33-
Warning: mb_chr(): Unsupported encoding "jis" in %s on line %d
33+
Warning: mb_chr(): Unsupported encoding "JIS" in %s on line %d
3434

35-
Warning: mb_chr(): Unsupported encoding "cp50222" in %s on line %d
35+
Warning: mb_chr(): Unsupported encoding "CP50222" in %s on line %d
3636

37-
Warning: mb_chr(): Unsupported encoding "utf-7" in %s on line %d
37+
Warning: mb_chr(): Unsupported encoding "UTF-7" in %s on line %d
3838
bool(false)
3939
bool(false)
4040
bool(false)

0 commit comments

Comments
 (0)