changeset 704:b6b8e7249666

Check that the buffer length is >= 1 before trying to access buf[len - 1]
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 26 Apr 2020 23:34:21 +0300
parents dbc71c000376
children dee28d507da7
files th_printf.c
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)--;