Skip to content

Commit 930ef9d

Browse files
committed
Fixed inconsequential bug in strtr()
1 parent d7bac4f commit 930ef9d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,7 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum,
30213021
res->shift->table_mask = SHIFT_TAB_SIZE - 1;
30223022
php_strtr_populate_shift(patterns, patnum, B, res->m, res->shift);
30233023

3024-
res->hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res->hash->entries), sizeof(*res->shift));
3024+
res->hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res->hash->entries), sizeof(*res->hash));
30253025
res->hash->table_mask = HASH_TAB_SIZE - 1;
30263026

30273027
res->patterns = safe_emalloc(patnum, sizeof(*res->patterns), 0);
@@ -3051,7 +3051,7 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum,
30513051
}
30523052
}
30533053
}
3054-
res->hash->entries[HASH_TAB_SIZE] = patnum;
3054+
res->hash->entries[HASH_TAB_SIZE] = patnum; /* OK, we effectively allocated SIZE+1 */
30553055
for (i = HASH_TAB_SIZE - 1; i >= 0; i--) {
30563056
if (res->hash->entries[i] == -1) {
30573057
res->hash->entries[i] = res->hash->entries[i + 1];

0 commit comments

Comments
 (0)