]> granicus.if.org Git - php/commitdiff
(PHP str_pad) Terminate string with a null.
authorAndrei Zmievski <andrei@php.net>
Mon, 12 Jun 2000 16:06:27 +0000 (16:06 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 12 Jun 2000 16:06:27 +0000 (16:06 +0000)
ext/standard/string.c

index 03bbc2900f630869adccba62657955ccb4bc2c58..ad267192fc5c96bbe4d56084f1e113c7cf7d663e 100644 (file)
@@ -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;
        }
 
 }