]> granicus.if.org Git - php/commitdiff
Fixed "Floating point exception" inside wordwrap()
authorIlia Alshanetsky <iliaa@php.net>
Sun, 22 Jul 2007 15:55:16 +0000 (15:55 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 22 Jul 2007 15:55:16 +0000 (15:55 +0000)
NEWS
ext/standard/string.c
ext/standard/tests/strings/wordwrap.phpt

diff --git a/NEWS b/NEWS
index 447afc44030c68eaf7b5f7a4963549981c5724e2..25e5b3d08aa0bf609bff86e15a0f4530d0d6e6dc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,8 @@ PHP                                                                        NEWS
 - Implemented FR #41884 (ReflectionClass::getDefaultProperties() does not handle 
   static attributes). (Tony)
 
+- Fixed "Floating point exception" inside wordwrap(). (Mattias Bengtsson,
+  Ilia)
 - Fixed crash in OpenSSL extension because of non-string passphrase. (Dmitry)
 - Fixed var_export() to use the new H modifier so that it can generate
   parseable PHP code for floats, independent of the locale. (Derick)
index acf6a8d526b89f106a28e16ff0bec4d564ab4958..cb8fa70ca33377a54eeeeaa979139eaf167d3f2b 100644 (file)
@@ -653,6 +653,11 @@ PHP_FUNCTION(wordwrap)
                RETURN_EMPTY_STRING();
        }
 
+       if (breakcharlen == 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Break string cannot be empty");
+               RETURN_FALSE;
+       }
+
        if (linelength == 0 && docut) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't force cut when width is zero.");
                RETURN_FALSE;
index 66104e3c77820fe8051d4eb04b6d894134789600..c1f3b05bda56a59902e46a090d2013f4363023fe 100644 (file)
@@ -27,6 +27,8 @@ $tests = <<<TESTS
 
 "123|==1234567890|==123" === wordwrap("123 1234567890 123", 10, "|==", 1)
 
+FALSE === @wordwrap(chr(0), 0, "")
+
 TESTS;
 
 include(dirname(__FILE__) . '/../../../../tests/quicktester.inc');