Skip to content

Commit e6d777b

Browse files
committed
Fix zero byte to zero codepoint
1 parent 952af91 commit e6d777b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ext/mbstring/mbstring.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,14 +3183,6 @@ PHP_FUNCTION(mb_levenshtein)
31833183
Z_PARAM_STR_OR_NULL(enc_name)
31843184
ZEND_PARSE_PARAMETERS_END();
31853185

3186-
if (ZSTR_LEN(string1) == 0) {
3187-
RETVAL_LONG(ZSTR_LEN(string2) * cost_ins);
3188-
}
3189-
3190-
if (ZSTR_LEN(string2) == 0) {
3191-
RETVAL_LONG(ZSTR_LEN(string1) * cost_del);
3192-
}
3193-
31943186
const mbfl_encoding *enc = php_mb_get_encoding(enc_name, 6);
31953187
if (!enc) {
31963188
RETURN_THROWS();
@@ -3217,6 +3209,14 @@ PHP_FUNCTION(mb_levenshtein)
32173209
unsigned char *in_2 = (unsigned char*)ZSTR_VAL(string2);
32183210
unsigned int state = 0;
32193211

3212+
if (strlen_1 == 0) {
3213+
RETVAL_LONG(strlen_2 * cost_ins);
3214+
}
3215+
3216+
if (strlen_2 == 0) {
3217+
RETVAL_LONG(strlen_1 * cost_ins);
3218+
}
3219+
32203220
zend_long c0, c1, c2;
32213221

32223222
p1 = safe_emalloc(strlen_1 + 1, sizeof(zend_long), 0);

0 commit comments

Comments
 (0)