Skip to content

Commit 465ecaa

Browse files
authored
ext/standard: zend_string_concat2() instead of manual memcpy (php#21567)
1 parent d28d59a commit 465ecaa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/standard/string.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,10 +2203,10 @@ PHP_FUNCTION(chunk_split)
22032203

22042204
if ((size_t)chunklen > ZSTR_LEN(str)) {
22052205
/* to maintain BC, we must return original string + ending */
2206-
result = zend_string_safe_alloc(ZSTR_LEN(str), 1, endlen, 0);
2207-
memcpy(ZSTR_VAL(result), ZSTR_VAL(str), ZSTR_LEN(str));
2208-
memcpy(ZSTR_VAL(result) + ZSTR_LEN(str), end, endlen);
2209-
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
2206+
result = zend_string_concat2(
2207+
ZSTR_VAL(str), ZSTR_LEN(str),
2208+
end, endlen
2209+
);
22102210
RETURN_NEW_STR(result);
22112211
}
22122212

0 commit comments

Comments
 (0)