Skip to content

Commit f1d259a

Browse files
ext/intl: Fix for the issue where strlen could potentially become negative (php#18477)
1 parent dd57332 commit f1d259a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ext/intl/grapheme/grapheme_string.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,10 @@ PHP_FUNCTION(grapheme_levenshtein)
994994
int32_t strlen_1, strlen_2;
995995
strlen_1 = grapheme_split_string(ustring1, ustring1_len, NULL, 0);
996996
strlen_2 = grapheme_split_string(ustring2, ustring2_len, NULL, 0);
997+
if (UNEXPECTED(strlen_1 < 0 || strlen_2 < 0)) {
998+
RETVAL_FALSE;
999+
goto out_ustring2;
1000+
}
9971001

9981002
if (strlen_1 == 0) {
9991003
RETVAL_LONG(strlen_2 * cost_ins);

0 commit comments

Comments
 (0)