@@ -144,7 +144,7 @@ static char Lookahead(char *word, int how_far)
144
144
* could be one though; or more too). */
145
145
#define Phonize (c ) { \
146
146
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); \
148
148
max_buffer_len += 2; \
149
149
} \
150
150
(*phoned_word)->val[p_idx++] = c; \
@@ -153,7 +153,8 @@ static char Lookahead(char *word, int how_far)
153
153
/* Slap a null character on the end of the phoned word */
154
154
#define End_Phoned_Word { \
155
155
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; \
157
158
} \
158
159
(*phoned_word)->val[p_idx] = '\0'; \
159
160
(*phoned_word)->len = p_idx; \
@@ -188,10 +189,10 @@ static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_
188
189
/*-- Allocate memory for our phoned_phrase --*/
189
190
if (max_phonemes == 0 ) { /* Assume largest possible */
190
191
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 );
192
193
} else {
193
194
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 );
195
196
}
196
197
197
198
0 commit comments