summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2000-06-12 16:06:27 +0000
committerAndrei Zmievski <andrei@php.net>2000-06-12 16:06:27 +0000
commitab99eb59fbaa7c974a9523785a5a7e3b0a4cacde (patch)
tree34d18ad15879fe4ebf50ea5b09f3ae457b61ca8c /ext
parentc250702c401fb8054c4269026931690fc48c619a (diff)
downloadphp-git-ab99eb59fbaa7c974a9523785a5a7e3b0a4cacde.tar.gz
(PHP str_pad) Terminate string with a null.
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/string.c5
1 files changed, 3 insertions, 2 deletions
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;
}
}