diff options
-rw-r--r-- | ext/standard/formatted_print.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 2d81fae2a5..8dcadfe7a6 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -373,26 +373,22 @@ php_sprintf_getnumber(char *buffer, int *pos) static char * php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC) { - zval ***args, **z_format; + zval ***args = NULL, **z_format; int argc, size = 240, inpos = 0, outpos = 0, temppos; int alignment, currarg, adjusting, argnum, width, precision; char *format, *result, padding; int always_sign; - argc = ZEND_NUM_ARGS(); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) { + return; + } /* verify the number of args */ if ((use_array && argc != (2 + format_offset)) || (!use_array && argc < (1 + format_offset))) { WRONG_PARAM_COUNT_WITH_RETVAL(NULL); } - args = (zval ***)safe_emalloc(argc, sizeof(zval *), 0); - if (zend_get_parameters_array_ex(argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT_WITH_RETVAL(NULL); - } - if (use_array) { int i = 1; zval ***newargs; @@ -690,6 +686,7 @@ PHP_FUNCTION(vsprintf) if ((result=php_formatted_print(ht, &len, 1, 0 TSRMLS_CC))==NULL) { RETURN_FALSE; } + RETVAL_STRINGL(result, len, 0); } /* }}} */ @@ -731,18 +728,17 @@ PHP_FUNCTION(vprintf) PHP_FUNCTION(fprintf) { php_stream *stream; - zval **arg1; + zval **arg1 = NULL; + zval **args = NULL; + int num_args; char *result; + zval **format; int len; - - if (ZEND_NUM_ARGS() < 2) { - WRONG_PARAM_COUNT; - } - - if (zend_get_parameters_ex(1, &arg1)==FAILURE) { - RETURN_FALSE; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z+", &arg1, &args) == FAILURE) { + return; } - + php_stream_from_zval(stream, arg1); if ((result=php_formatted_print(ht, &len, 0, 1 TSRMLS_CC))==NULL) { |