felipe Mon Feb 25 22:56:47 2008 UTC
Modified files:
/php-src/ext/standard metaphone.c
/php-src/ext/standard/tests/strings bug44242.phpt
Log:
MFB: Fixed bug #44242 (metaphone('CMXFXM') crashes PHP)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/metaphone.c?r1=1.36&r2=1.37&diff_format=u
Index: php-src/ext/standard/metaphone.c
diff -u php-src/ext/standard/metaphone.c:1.36
php-src/ext/standard/metaphone.c:1.37
--- php-src/ext/standard/metaphone.c:1.36 Mon Dec 31 07:12:16 2007
+++ php-src/ext/standard/metaphone.c Mon Feb 25 22:56:47 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: metaphone.c,v 1.36 2007/12/31 07:12:16 sebastian Exp $ */
+/* $Id: metaphone.c,v 1.37 2008/02/25 22:56:47 felipe Exp $ */
/*
Based on CPANs "Text-Metaphone-1.96" by Michael G Schwern <[EMAIL
PROTECTED]>
@@ -151,7 +151,12 @@
(*phoned_word)[p_idx++] = c; \
}
/* Slap a null character on the end of the phoned word */
-#define End_Phoned_Word {(*phoned_word)[p_idx] = '\0';}
+#define End_Phoned_Word { \
+ if (p_idx ==
max_buffer_len) { \
+ *phoned_word =
erealloc(*phoned_word, max_buffer_len + 1); \
+ } \
+ (*phoned_word)[p_idx] =
'\0'; \
+ }
/* How long is the phoned word? */
#define Phone_Len (p_idx)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug44242.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/bug44242.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/bug44242.phpt:1.2
--- /dev/null Mon Feb 25 22:56:47 2008
+++ php-src/ext/standard/tests/strings/bug44242.phpt Mon Feb 25 22:56:47 2008
@@ -0,0 +1,14 @@
+--TEST--
+Bug #44242 (metaphone('CMXFXM') crashes PHP)
+--FILE--
+<?php
+
+echo metaphone('CMXFXZ'), "\n";
+echo metaphone('CMXFXV'), "\n";
+echo metaphone('CMXFXZXZ'), "\n";
+
+?>
+--EXPECT--
+KMKSFKSS
+KMKSFKSF
+KMKSFKSSKSS
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php