]> granicus.if.org Git - php/commitdiff
Avoding memory allocation
authorXinchen Hui <laruence@gmail.com>
Mon, 26 Feb 2018 08:48:49 +0000 (16:48 +0800)
committerXinchen Hui <laruence@gmail.com>
Mon, 26 Feb 2018 08:48:49 +0000 (16:48 +0800)
ext/standard/string.c

index 12e91dc11234c14146a6ac49fde1e7b4feea9fd2..969b56e9e489169e86a51c7d7b3153c0993be56e 100644 (file)
@@ -5654,7 +5654,7 @@ PHP_FUNCTION(str_pad)
        /* If resulting string turns out to be shorter than input string,
           we simply copy the input and return. */
        if (pad_length < 0  || (size_t)pad_length <= ZSTR_LEN(input)) {
-               RETURN_STRINGL(ZSTR_VAL(input), ZSTR_LEN(input));
+               RETURN_STR_COPY(input);
        }
 
        if (pad_str_len == 0) {