diff options
author | Jani Taskinen <jani@php.net> | 2007-07-23 11:47:44 +0000 |
---|---|---|
committer | Jani Taskinen <jani@php.net> | 2007-07-23 11:47:44 +0000 |
commit | 7bfd857fa1e762c4ac5c3abd3eba4c95406af147 (patch) | |
tree | 48c63c5b19bd6008e6b7982afc86b1837d888a05 | |
parent | 6b7c17e222610a60d6e806342ab3150bc709aa52 (diff) | |
download | php-git-7bfd857fa1e762c4ac5c3abd3eba4c95406af147.tar.gz |
MFB: Fixed "Floating point exception" inside wordwrap()
-rw-r--r-- | ext/standard/string.c | 5 | ||||
-rw-r--r-- | ext/standard/tests/strings/wordwrap.phpt | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index 8ba1f5371d..0abd0b4cc5 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -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; diff --git a/ext/standard/tests/strings/wordwrap.phpt b/ext/standard/tests/strings/wordwrap.phpt index 66104e3c77..c1f3b05bda 100644 --- a/ext/standard/tests/strings/wordwrap.phpt +++ b/ext/standard/tests/strings/wordwrap.phpt @@ -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'); |