From: Andrei Zmievski Date: Mon, 12 Jun 2000 16:06:27 +0000 (+0000) Subject: (PHP str_pad) Terminate string with a null. X-Git-Tag: php-4.0.1RC~257 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab99eb59fbaa7c974a9523785a5a7e3b0a4cacde;p=php (PHP str_pad) Terminate string with a null. --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 03bbc2900f..ad267192fc 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2610,7 +2610,7 @@ PHP_FUNCTION(str_pad) pad_str_len = Z_STRLEN_PP(pad_string); } - result = (char *)emalloc(pad_length_abs); + result = (char *)emalloc(pad_length_abs+1); /* If positive, we pad on the right and copy the input now. */ if (Z_LVAL_PP(pad_length) > 0) { @@ -2628,6 +2628,7 @@ PHP_FUNCTION(str_pad) memcpy(result + result_len, Z_STRVAL_PP(input), Z_STRLEN_PP(input)); result_len += Z_STRLEN_PP(input); } + result[result_len] = '\0'; RETURN_STRINGL(result, result_len, 0); } @@ -2668,7 +2669,7 @@ PHP_FUNCTION(sscanf) efree(args); if (SCAN_ERROR_WRONG_PARAM_COUNT == result) { - WRONG_PARAM_COUNT + WRONG_PARAM_COUNT; } }