com php-src: Fixed wrong zend_string usage in ext/stand ard/tests/strings/bug47443.php: ext/standard/me taphone.c

From: Date: Sun, 23 Feb 2014 11:04:40 +0000
Subject: com php-src: Fixed wrong zend_string usage in ext/stand ard/tests/strings/bug47443.php: ext/standard/me taphone.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77988@lists.php.net to get a copy of this message
Commit: bd3bd63571af24ecd8872d4b3ab888baef7d7024 Author: Xinchen Hui <laruence@gmail.com> Sun, 23 Feb 2014 19:04:40 +0800 Parents: 6a856d4aa94db68942ac489abaf621dd387d9753 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bd3bd63571af24ecd8872d4b3ab888baef7d7024 Log: Fixed wrong zend_string usage in ext/standard/tests/strings/bug47443.php Bugs: https://bugs.php.net/47443 Changed paths: M ext/standard/metaphone.c Diff: diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c index 290b63e...9d22868 100644 --- a/ext/standard/metaphone.c +++ b/ext/standard/metaphone.c @@ -144,7 +144,7 @@ static char Lookahead(char *word, int how_far) * could be one though; or more too). */ #define Phonize(c) { \ if (p_idx >= max_buffer_len) { \ - *phoned_word = STR_REALLOC(*phoned_word, 1 + max_buffer_len, 0); \ + *phoned_word = STR_REALLOC(*phoned_word, 2 * sizeof(char) + max_buffer_len, 0); \ max_buffer_len += 2; \ } \ (*phoned_word)->val[p_idx++] = c; \ @@ -153,7 +153,8 @@ static char Lookahead(char *word, int how_far) /* Slap a null character on the end of the phoned word */ #define End_Phoned_Word { \ if (p_idx == max_buffer_len) { \ - *phoned_word = STR_REALLOC(*phoned_word, max_buffer_len, 0); \ + *phoned_word = STR_REALLOC(*phoned_word, 1 * sizeof(char) + max_buffer_len, 0); \ + max_buffer_len += 1; \ } \ (*phoned_word)->val[p_idx] = '\0'; \ (*phoned_word)->len = p_idx; \ @@ -188,10 +189,10 @@ static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_ /*-- Allocate memory for our phoned_phrase --*/ if (max_phonemes == 0) { /* Assume largest possible */ max_buffer_len = word_len; - *phoned_word = safe_emalloc(sizeof(char), word_len, 1); + *phoned_word = STR_ALLOC(sizeof(char) * word_len + 1, 0); } else { max_buffer_len = max_phonemes; - *phoned_word = safe_emalloc(sizeof(char), max_phonemes, 1); + *phoned_word = STR_ALLOC(sizeof(char) * max_phonemes + 1, 0); }

« previous php.cvs (#77988) next »