From 25b42ae3b64e90508711cd095e4d2f9fa8a55450 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Fri, 22 Mar 2002 09:09:18 +0000 Subject: [PATCH] - Fix handling of zero'th argument for sprintf()'s argument swapping code (Patch by Morten Poulsen ) --- ext/standard/formatted_print.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 57a32bef1a..7a11b3a5f0 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -480,6 +480,14 @@ php_formatted_print(int ht, int *len, int use_array TSRMLS_DC) while (isdigit((int)format[temppos])) temppos++; if (format[temppos] == '$') { argnum = php_sprintf_getnumber(format, &inpos); + + if (argnum == 0) { + efree(result); + efree(args); + php_error(E_WARNING, "%s(): zero is not a valid argument number", get_active_function_name(TSRMLS_C)); + return NULL; + } + inpos++; /* skip the '$' */ } else { argnum = currarg++; -- 2.40.0