From eddb79e0ab1ffef0507db3803494398a4f4dc1e9 Mon Sep 17 00:00:00 2001 From: Jani Taskinen Date: Thu, 23 Jul 2009 14:54:04 +0000 Subject: [PATCH] - Fixed bug #48802 (printf() returns incorrect outputted length) --- NEWS | 1 + ext/standard/formatted_print.c | 12 ++++++------ sapi/cli/php_cli.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index fa59891672..af3b0cfc9b 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ PHP NEWS option is an array). (David Zülke) - Fixed bug #48913 (Too long error code strings in pdo_odbc driver). (naf at altlinux dot ru, Felipe) +- Fixed bug #48802 (printf() returns incorrect outputted length). (Jani) - Fixed bug #48788 (RecursiveDirectoryIterator doesn't descend into symlinked directories). (Ilia) - Fixed bug #48763 (ZipArchive produces corrupt archive). (dani dot church at diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 1da0b37eee..8666735e07 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -700,14 +700,14 @@ PHP_FUNCTION(vsprintf) PHP_FUNCTION(user_printf) { char *result; - int len; + int len, rlen; if ((result=php_formatted_print(ht, &len, 0, 0 TSRMLS_CC))==NULL) { RETURN_FALSE; } - PHPWRITE(result, len); + rlen = PHPWRITE(result, len); efree(result); - RETURN_LONG(len); + RETURN_LONG(rlen); } /* }}} */ @@ -716,14 +716,14 @@ PHP_FUNCTION(user_printf) PHP_FUNCTION(vprintf) { char *result; - int len; + int len, rlen; if ((result=php_formatted_print(ht, &len, 1, 0 TSRMLS_CC))==NULL) { RETURN_FALSE; } - PHPWRITE(result, len); + rlen = PHPWRITE(result, len); efree(result); - RETURN_LONG(len); + RETURN_LONG(rlen); } /* }}} */ diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 0561416f12..1545dabe03 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -298,7 +298,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ remaining -= ret; } - return str_length; + return (ptr - str); } /* }}} */ -- 2.40.0