From 349936c93e83ab79d917473ee491a4c7be7f7db2 Mon Sep 17 00:00:00 2001 From: jim winstead Date: Mon, 18 Mar 2002 02:00:57 +0000 Subject: [PATCH] Fix calculation of output buffer size in wordwrap(). (Thanks to Wez.) --- ext/standard/string.c | 2 +- ext/standard/tests/strings/wordwrap.phpt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index e255dc09b5..09b2e46941 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -662,7 +662,7 @@ PHP_FUNCTION(wordwrap) else { /* Multiple character line break or forced cut */ if (linelength > 0) { - newtextlen = textlen + (textlen/linelength) * breakcharlen + 1; + newtextlen = textlen + (textlen/linelength + 1) * breakcharlen + 1; } else { newtextlen = textlen * (breakcharlen + 1) + 1; diff --git a/ext/standard/tests/strings/wordwrap.phpt b/ext/standard/tests/strings/wordwrap.phpt index d367b3a82b..3fc8f1d880 100644 --- a/ext/standard/tests/strings/wordwrap.phpt +++ b/ext/standard/tests/strings/wordwrap.phpt @@ -27,6 +27,8 @@ $tests = <<