From 18dc9044f51c0d694c0b05e29d022787c9749617 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 1 Apr 2020 04:29:20 +0200 Subject: [PATCH] Fix bug 79441 --- ext/mbstring/mbstring.c | 2 +- ext/mbstring/tests/bug79441.phpt | 13 +++++++++++++ ext/mbstring/tests/mb_chr.phpt | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 ext/mbstring/tests/bug79441.phpt 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-- + +--FILE-- + +--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) -- 2.40.0