# HG changeset patch # User Matti Hamalainen # Date 1587933261 -10800 # Node ID b6b8e7249666296263e258bf6bb7c03a8eb8897d # Parent dbc71c0003765ae6eb9bd8cc25c5052e7b320678 Check that the buffer length is >= 1 before trying to access buf[len - 1] diff -r dbc71c000376 -r b6b8e7249666 th_printf.c --- a/th_printf.c Sun Apr 26 23:30:17 2020 +0300 +++ b/th_printf.c Sun Apr 26 23:34:21 2020 +0300 @@ -121,7 +121,7 @@ (void) prec; // This is not very nice - if (buf[len - 1] != '0') + if (len < 1 || buf[len - 1] != '0') { if (*prec > 0) (*prec)--;