summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-04-01 04:29:20 +0200
committerGeorge Peter Banyard <girgias@php.net>2020-04-01 04:29:20 +0200
commit18dc9044f51c0d694c0b05e29d022787c9749617 (patch)
tree152b5dbb834d5cdd33144dab87f589d32a7e70a5
parent33226c3a176602fb9f5a25a344ca0f539b6c1dd9 (diff)
downloadphp-git-18dc9044f51c0d694c0b05e29d022787c9749617.tar.gz
Fix bug 79441
-rw-r--r--ext/mbstring/mbstring.c2
-rw-r--r--ext/mbstring/tests/bug79441.phpt13
-rw-r--r--ext/mbstring/tests/mb_chr.phpt6
3 files changed, 17 insertions, 4 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 49adb167b2..0f466a02ee 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -4931,7 +4931,7 @@ static inline zend_string *php_mb_chr(zend_long cp, const char *enc_name)
no_enc = enc->no_encoding;
if (php_mb_is_unsupported_no_encoding(no_enc)) {
- php_error_docref(NULL, E_WARNING, "Unsupported encoding \"%s\"", enc_name);
+ php_error_docref(NULL, E_WARNING, "Unsupported encoding \"%s\"", enc->name);
return NULL;
}
diff --git a/ext/mbstring/tests/bug79441.phpt b/ext/mbstring/tests/bug79441.phpt
new file mode 100644
index 0000000000..32d8df99dd
--- /dev/null
+++ b/ext/mbstring/tests/bug79441.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #79441 Segfault in mb_chr() if internal encoding is unsupported
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+
+mb_internal_encoding("utf-7");
+mb_chr(0xd800);
+
+?>
+--EXPECTF--
+Warning: mb_chr(): Unsupported encoding "UTF-7" in %s on line %d
diff --git a/ext/mbstring/tests/mb_chr.phpt b/ext/mbstring/tests/mb_chr.phpt
index d61178af4d..078288f099 100644
--- a/ext/mbstring/tests/mb_chr.phpt
+++ b/ext/mbstring/tests/mb_chr.phpt
@@ -30,11 +30,11 @@ Warning: mb_chr(): Unknown encoding "typo" in %s on line %d
Warning: mb_chr(): Unsupported encoding "pass" in %s on line %d
-Warning: mb_chr(): Unsupported encoding "jis" in %s on line %d
+Warning: mb_chr(): Unsupported encoding "JIS" in %s on line %d
-Warning: mb_chr(): Unsupported encoding "cp50222" in %s on line %d
+Warning: mb_chr(): Unsupported encoding "CP50222" in %s on line %d
-Warning: mb_chr(): Unsupported encoding "utf-7" in %s on line %d
+Warning: mb_chr(): Unsupported encoding "UTF-7" in %s on line %d
bool(false)
bool(false)
bool(false)