]> granicus.if.org Git - php/commitdiff
MFB: Fixed "Floating point exception" inside wordwrap()
authorJani Taskinen <jani@php.net>
Mon, 23 Jul 2007 11:47:44 +0000 (11:47 +0000)
committerJani Taskinen <jani@php.net>
Mon, 23 Jul 2007 11:47:44 +0000 (11:47 +0000)
ext/standard/string.c
ext/standard/tests/strings/wordwrap.phpt

index 8ba1f5371d8e29fe532657e93749affb78c0f55a..0abd0b4cc5c01915d1bad15c7477cba1727c05cf 100644 (file)
@@ -856,6 +856,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');