]> granicus.if.org Git - php/commitdiff
Fix Bug #79448 0 is a valid Unicode codepoint, but mb_substitute_character(0) fails
authorGeorge Peter Banyard <girgias@php.net>
Fri, 3 Apr 2020 19:16:04 +0000 (21:16 +0200)
committerGeorge Peter Banyard <girgias@php.net>
Fri, 3 Apr 2020 19:18:45 +0000 (21:18 +0200)
ext/mbstring/mbstring.c
ext/mbstring/tests/bug79448.phpt [new file with mode: 0644]

index 0f466a02ee491a6a2b3a887c0e7b056d538d0864..ba30e05c27d4d4d59fc77c4f8fb4a9275553f37a 100644 (file)
@@ -2038,7 +2038,7 @@ PHP_FUNCTION(mb_detect_order)
 
 static inline int php_mb_check_code_point(zend_long cp)
 {
-       if (cp <= 0 || cp >= 0x110000) {
+       if (cp < 0 || cp >= 0x110000) {
                /* Out of Unicode range */
                return 0;
        }
diff --git a/ext/mbstring/tests/bug79448.phpt b/ext/mbstring/tests/bug79448.phpt
new file mode 100644 (file)
index 0000000..0905294
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #79448     0 is a valid Unicode codepoint, but mb_substitute_character(0) fails
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+// 0 is a valid codepoint regardless of encoding
+var_dump(mb_substitute_character(0));
+?>
+--EXPECT--
+bool(true)