From 3fea65b0dc1dedd528b334da9c5a705de846ab6e Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 22 Jul 2007 15:55:16 +0000 Subject: [PATCH] Fixed "Floating point exception" inside wordwrap() --- NEWS | 2 ++ ext/standard/string.c | 5 +++++ ext/standard/tests/strings/wordwrap.phpt | 2 ++ 3 files changed, 9 insertions(+) diff --git a/NEWS b/NEWS index 447afc4403..25e5b3d08a 100644 --- 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) diff --git a/ext/standard/string.c b/ext/standard/string.c index acf6a8d526..cb8fa70ca3 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -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; 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 = <<