diff --git a/ext/standard/string.c b/ext/standard/string.c index 75bd5f1d2f..fb09f3686b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2999,9 +2999,9 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, } } res->hash->entries[HASH_TAB_SIZE] = patnum; /* OK, we effectively allocated SIZE+1 */ - for (i = HASH_TAB_SIZE - 1; i >= 0; i--) { - if (res->hash->entries[i] == -1) { - res->hash->entries[i] = res->hash->entries[i + 1]; + for (i = HASH_TAB_SIZE; i > 0; i--) { + if (res->hash->entries[i-1] == -1) { + res->hash->entries[i-1] = res->hash->entries[i]; } }