Skip to content

Commit bfb0e87

Browse files
committed
final fix for hebrev()
1 parent 5351aa9 commit bfb0e87

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4129,7 +4129,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
41294129

41304130
while (1) {
41314131
char_count=0;
4132-
while ((!max_chars || char_count < max_chars) && begin > 0) {
4132+
while ((!max_chars || max_chars > 0 && char_count < max_chars) && begin > 0) {
41334133
char_count++;
41344134
begin--;
41354135
if (begin <= 0 || _isnewline(heb_str[begin])) {
@@ -4140,7 +4140,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
41404140
break;
41414141
}
41424142
}
4143-
if (char_count == max_chars) { /* try to avoid breaking words */
4143+
if (max_chars >= 0 && char_count == max_chars) { /* try to avoid breaking words */
41444144
zend_str_size_int new_char_count=char_count, new_begin=begin;
41454145

41464146
while (new_char_count > 0) {

0 commit comments

Comments
 (0)