From: Jani Taskinen Date: Thu, 23 Jul 2009 14:54:04 +0000 (+0000) Subject: - Fixed bug #48802 (printf() returns incorrect outputted length) X-Git-Tag: php-5.4.0alpha1~191^2~3013 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b10dc002639b953775a5faeac3c6f0dad18f1762;p=php - Fixed bug #48802 (printf() returns incorrect outputted length) --- diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 58b4ce113f..ad2845cea7 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -1299,7 +1299,7 @@ PHP_FUNCTION(vsprintf) Output a formatted string */ PHP_FUNCTION(user_printf) { - int len; + int len, rlen; zstr result; result = php_u_formatted_print(ht, &len, 0, 0, PHP_OUTPUT TSRMLS_CC); @@ -1307,9 +1307,9 @@ PHP_FUNCTION(user_printf) RETURN_FALSE; } - PHPWRITE(result.s, len); + rlen = PHPWRITE(result.s, len); efree(result.v); - RETURN_LONG(len); + RETURN_LONG(rlen); } /* }}} */ @@ -1317,7 +1317,7 @@ PHP_FUNCTION(user_printf) Output a formatted string */ PHP_FUNCTION(vprintf) { - int len; + int len, rlen; zstr result; result = php_u_formatted_print(ht, &len, 1, 0, PHP_OUTPUT TSRMLS_CC); @@ -1325,9 +1325,9 @@ PHP_FUNCTION(vprintf) RETURN_FALSE; } - PHPWRITE(result.s, len); + rlen = PHPWRITE(result.s, len); efree(result.v); - RETURN_LONG(len); + RETURN_LONG(rlen); } /* }}} */ diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index c7dca71179..a959ba0f69 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -302,7 +302,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ remaining -= ret; } - return str_length; + return (ptr - str); } /* }}} */