diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 9862f7895fa..4805f2ca482 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -1569,7 +1569,8 @@ consult the installation file that came with this distribution, or visit \n\ } } - s = malloc(++len + 1); + len += 2; + s = malloc(len); *s = '\0'; /* we are pretending it came from the environment */ for (i = php_optind; i < argc; i++) { strlcat(s, argv[i], len);