Skip to content

Commit 5cdb16a

Browse files
author
Thies C. Arntzen
committed
(explode) fixed newly introduced bug (them shall check twice *before* committing!)
1 parent 3d160b5 commit 5cdb16a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ext/standard/string.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,15 @@ PHPAPI void php_explode(pval *delim, pval *str, pval *return_value)
221221

222222
if (p2 == NULL) {
223223
add_index_stringl(return_value, i++, p1, str->value.str.len, 1);
224-
} else do {
225-
add_index_stringl(return_value, i++, p1, p2-p1, 1);
226-
p1 = p2 + delim->value.str.len;
227-
} while ((p2 = php_memnstr(p1, delim->value.str.val, delim->value.str.len, endp)) != NULL);
224+
} else {
225+
do {
226+
add_index_stringl(return_value, i++, p1, p2-p1, 1);
227+
p1 = p2 + delim->value.str.len;
228+
} while ((p2 = php_memnstr(p1, delim->value.str.val, delim->value.str.len, endp)) != NULL);
228229

229-
if (p1 <= endp) {
230-
add_index_stringl(return_value, i++, p1, endp-p1, 1);
230+
if (p1 <= endp) {
231+
add_index_stringl(return_value, i++, p1, endp-p1, 1);
232+
}
231233
}
232234
}
233235

0 commit comments

Comments
 (0)