diff options
author | Marco Paland <marco@paland.com> | 2018-09-14 13:48:27 +0200 |
---|---|---|
committer | Marco Paland <marco@paland.com> | 2018-09-14 13:48:27 +0200 |
commit | 6dae1687b5fd4dd7ee104079da0df906fe393263 (patch) | |
tree | 9769d32b33e0ab86d2285b71d62398f589a5f296 /printf.c | |
parent | f8a2be378d6df840ee16e0019435cadc659348c1 (diff) | |
download | printf-6dae1687b5fd4dd7ee104079da0df906fe393263.tar.gz printf-6dae1687b5fd4dd7ee104079da0df906fe393263.tar.bz2 printf-6dae1687b5fd4dd7ee104079da0df906fe393263.zip |
fix(printf): fix negative argument precision
Fixes #25
Diffstat (limited to 'printf.c')
-rw-r--r-- | printf.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -464,7 +464,8 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const precision = _atoi(&format);
}
else if (*format == '*') {
- precision = (unsigned int)va_arg(va, int);
+ const int prec = (int)va_arg(va, int);
+ precision = prec > 0 ? (unsigned int)prec : 0U;
format++;
}
}
|