From c85a9abc4ceb2b296cb07ccd1ab38b2be6eb0951 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 26 Jan 2005 00:01:26 +0000 Subject: [PATCH] Fixed bug #29733 (printf() handles repeated placeholders wrong). # Original patch by bugs dot php dot net at bluetwanger dot de --- ext/standard/formatted_print.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 75cf0205d8..8119ce2f90 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -545,12 +545,6 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC php_sprintf_appendchar(&result, &outpos, &size, '%' TSRMLS_CC); inpos += 2; } else { - if (currarg >= argc && format[inpos + 1] != '%') { - efree(result); - efree(args); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too few arguments"); - return NULL; - } /* starting a new format specifier, reset variables */ alignment = ALIGN_RIGHT; adjusting = 0; @@ -581,13 +575,6 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC } argnum += format_offset; - - if (argnum >= argc) { - efree(result); - efree(args); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too few arguments"); - return NULL; - } /* after argnum comes modifiers */ PRINTF_DEBUG(("sprintf: looking for modifiers\n" @@ -643,6 +630,13 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC argnum = currarg++ + format_offset; } + if (argnum >= argc) { + efree(result); + efree(args); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too few arguments"); + return NULL; + } + if (format[inpos] == 'l') { inpos++; } -- 2.40.0