Avoid potential integer overflow (#18485)

This commit is contained in:
Niels Dossche 2025-05-02 15:50:24 +02:00 committed by GitHub
parent 59056937bf
commit 60e9fb5a1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1053,8 +1053,8 @@ PHP_FUNCTION(grapheme_levenshtein)
} }
zend_long *p1, *p2, *tmp; zend_long *p1, *p2, *tmp;
p1 = safe_emalloc(strlen_2 + 1, sizeof(zend_long), 0); p1 = safe_emalloc((size_t) strlen_2 + 1, sizeof(zend_long), 0);
p2 = safe_emalloc(strlen_2 + 1, sizeof(zend_long), 0); p2 = safe_emalloc((size_t) strlen_2 + 1, sizeof(zend_long), 0);
for (i2 = 0; i2 <= strlen_2; i2++) { for (i2 = 0; i2 <= strlen_2; i2++) {
p1[i2] = i2 * cost_ins; p1[i2] = i2 * cost_ins;