]> granicus.if.org Git - php/commitdiff
Fixed inconsequential bug in strtr()
authorGustavo Lopes <gustavo@icemobile.com>
Tue, 15 Jan 2013 16:25:59 +0000 (17:25 +0100)
committerGustavo Lopes <gustavo@icemobile.com>
Tue, 15 Jan 2013 16:25:59 +0000 (17:25 +0100)
ext/standard/string.c

index 953dfd17fb00cc8602d84697dc830a86e2525b74..58b5483651a8306652db3ae715a1c12cf6cf0cd6 100644 (file)
@@ -3021,7 +3021,7 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum,
        res->shift->table_mask = SHIFT_TAB_SIZE - 1;
        php_strtr_populate_shift(patterns, patnum, B, res->m, res->shift);
 
-       res->hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res->hash->entries), sizeof(*res->shift));
+       res->hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res->hash->entries), sizeof(*res->hash));
        res->hash->table_mask = HASH_TAB_SIZE - 1;
 
        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,
                        }
                }
        }
-       res->hash->entries[HASH_TAB_SIZE] = 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];