Skip to content

Commit bd3bd63

Browse files
committed
Fixed wrong zend_string usage in ext/standard/tests/strings/bug47443.php
1 parent 6a856d4 commit bd3bd63

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ext/standard/metaphone.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static char Lookahead(char *word, int how_far)
144144
* could be one though; or more too). */
145145
#define Phonize(c) { \
146146
if (p_idx >= max_buffer_len) { \
147-
*phoned_word = STR_REALLOC(*phoned_word, 1 + max_buffer_len, 0); \
147+
*phoned_word = STR_REALLOC(*phoned_word, 2 * sizeof(char) + max_buffer_len, 0); \
148148
max_buffer_len += 2; \
149149
} \
150150
(*phoned_word)->val[p_idx++] = c; \
@@ -153,7 +153,8 @@ static char Lookahead(char *word, int how_far)
153153
/* Slap a null character on the end of the phoned word */
154154
#define End_Phoned_Word { \
155155
if (p_idx == max_buffer_len) { \
156-
*phoned_word = STR_REALLOC(*phoned_word, max_buffer_len, 0); \
156+
*phoned_word = STR_REALLOC(*phoned_word, 1 * sizeof(char) + max_buffer_len, 0); \
157+
max_buffer_len += 1; \
157158
} \
158159
(*phoned_word)->val[p_idx] = '\0'; \
159160
(*phoned_word)->len = p_idx; \
@@ -188,10 +189,10 @@ static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_
188189
/*-- Allocate memory for our phoned_phrase --*/
189190
if (max_phonemes == 0) { /* Assume largest possible */
190191
max_buffer_len = word_len;
191-
*phoned_word = safe_emalloc(sizeof(char), word_len, 1);
192+
*phoned_word = STR_ALLOC(sizeof(char) * word_len + 1, 0);
192193
} else {
193194
max_buffer_len = max_phonemes;
194-
*phoned_word = safe_emalloc(sizeof(char), max_phonemes, 1);
195+
*phoned_word = STR_ALLOC(sizeof(char) * max_phonemes + 1, 0);
195196
}
196197

197198

0 commit comments

Comments
 (0)