From 8c3e4ccd721e79ec2aa29f96698d50622153f0ae Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 30 May 2021 18:06:10 +0200 Subject: [PATCH] AK: Honor variable precision argument when formatting printf didn't check whether the additional integer variable belongs to the field width specifier or to the precision specifier, and always applied it to the field width instead. Implement the case distinction that we already use in literal width and precision specifiers for the variable version as well so that they are correctly attributed. --- AK/PrintfImplementation.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 318e1d06c1..0af3faf2f0 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -452,7 +452,13 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm } } if (*p == '*') { - state.field_width = NextArgument()(ap); + if (state.dot) { + state.has_fraction_length = true; + state.fraction_length = NextArgument()(ap); + } else { + state.field_width = NextArgument()(ap); + } + if (*(p + 1)) goto one_more; }