Mercurial > hg > th-libs
comparison th_printf.c @ 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 | 284d5b789b7c |
children | 4ca6a3b30fe8 |
comparison
equal
deleted
inserted
replaced
703:dbc71c000376 | 704:b6b8e7249666 |
---|---|
119 (void) vret; | 119 (void) vret; |
120 (void) flags; | 120 (void) flags; |
121 (void) prec; | 121 (void) prec; |
122 | 122 |
123 // This is not very nice | 123 // This is not very nice |
124 if (buf[len - 1] != '0') | 124 if (len < 1 || buf[len - 1] != '0') |
125 { | 125 { |
126 if (*prec > 0) | 126 if (*prec > 0) |
127 (*prec)--; | 127 (*prec)--; |
128 | 128 |
129 *outlen = 1; | 129 *outlen = 1; |