summaryrefslogtreecommitdiff
path: root/ext/standard/formatted_print.c
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2002-03-22 09:09:18 +0000
committerDerick Rethans <derick@php.net>2002-03-22 09:09:18 +0000
commit25b42ae3b64e90508711cd095e4d2f9fa8a55450 (patch)
tree78d36785ed22afe2fb263e138dc95cac6d217219 /ext/standard/formatted_print.c
parentc7bee303744c4e889aadc7ef9bbe05b94b6e2bd3 (diff)
downloadphp-git-25b42ae3b64e90508711cd095e4d2f9fa8a55450.tar.gz
- Fix handling of zero'th argument for sprintf()'s argument swapping code
(Patch by Morten Poulsen <morten@afdelingp.dk>)
Diffstat (limited to 'ext/standard/formatted_print.c')
-rw-r--r--ext/standard/formatted_print.c8
1 files changed, 8 insertions, 0 deletions
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++;