mirror of
https://github.com/php/php-src.git
synced 2025-01-18 09:43:36 +08:00
Fixed bug #29733 (printf() handles repeated placeholders wrong).
# Original patch by bugs dot php dot net at bluetwanger dot de
This commit is contained in:
parent
9ab8deb33c
commit
c85a9abc4c
@ -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++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user