summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mbstring/mbstring.c12
-rw-r--r--ext/mbstring/tests/mb_ord.phpt8
2 files changed, 10 insertions, 10 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 4215d7b7a4..1a5f512765 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -4335,6 +4335,8 @@ static inline zend_long php_mb_ord(const char *str, size_t str_len, zend_string
const mbfl_encoding *enc;
enum mbfl_no_encoding no_enc;
+ ZEND_ASSERT(str_len > 0);
+
enc = php_mb_get_encoding(enc_name, enc_name_arg_num);
if (!enc) {
return -2;
@@ -4346,11 +4348,6 @@ static inline zend_long php_mb_ord(const char *str, size_t str_len, zend_string
return -2;
}
- if (str_len == 0) {
- php_error_docref(NULL, E_WARNING, "Empty string");
- return -1;
- }
-
{
mbfl_wchar_device dev;
mbfl_convert_filter *filter;
@@ -4396,6 +4393,11 @@ PHP_FUNCTION(mb_ord)
Z_PARAM_STR(enc)
ZEND_PARSE_PARAMETERS_END();
+ if (str_len == 0) {
+ zend_argument_value_error(1, "must not be empty");
+ RETURN_THROWS();
+ }
+
cp = php_mb_ord(str, str_len, enc, 2);
if (0 > cp) {
diff --git a/ext/mbstring/tests/mb_ord.phpt b/ext/mbstring/tests/mb_ord.phpt
index 5c7fdf3168..56e8d4a814 100644
--- a/ext/mbstring/tests/mb_ord.phpt
+++ b/ext/mbstring/tests/mb_ord.phpt
@@ -50,15 +50,13 @@ try {
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
-;
+
?>
---EXPECTF--
+--EXPECT--
bool(true)
bool(true)
bool(true)
-
-Warning: mb_ord(): Empty string in %s on line %d
-bool(false)
+mb_ord(): Argument #1 ($str) must not be empty
mb_ord(): Argument #2 ($encoding) must be a valid encoding, "typo" given
mb_ord() does not support the "pass" encoding
mb_ord() does not support the "JIS" encoding