<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/79988>79988</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
libc/src/stdio/scanf_core/float_converter.cpp: 2 * sanity check in wrong place ?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dcb314
</td>
</tr>
</table>
<pre>
Static analyser cppcheck says
1.
libc/src/stdio/scanf_core/float_converter.cpp:60:44: style: Array index 'inf_index' is used before limits check. [arrayIndexThenCheck]
Source code is
for (; to_lower(cur_char) == inf_string[inf_index] &&
inf_index < sizeof(inf_string) && out_str.length() < max_width;
++inf_index) {
Suggest move sanity check to before use.
2.
ibc/src/stdio/scanf_core/float_converter.cpp:83:44: style: Array index 'nan_index' is used before limits check. [arrayIndexThenCheck]
Duplicate.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU8FunDAQ_ZrhMgoCGxY4cNgNQuo5va-MGcCt10a2SbL9-sokTXZ7qRQVIdtjzYzfm6cnvFezIWqhPEHZJWILi3XtKAeeF8lgx2v7FERQEoUR-urJoVxXuZD8iV5cPWQdZMe3NU9vI60GCaz3bl_DqGzcpTDTWVpHwPpJWxHO0ppncoFcKtcV-PGQAT8WBfAj-nDVFA9H58QVlRnpFYFVykznPQBWofK4eRpxoMk6Qq0uKnjcEaYI5UnE2m8x-_tC5jHeQ9ndIn2ym5OE0o6E6o4RIuJkHQKrgZ8w2LO2L-SA1XJzZ7kIB6xB4B3wDiMqH5wyM5SnT4hlh8AO8f9o-f595CDwR_TqF9kJWH3TJzbfa9FuIV6mmswclohnf_gRL-L1_KLGsAA__fUCsBOwGySxojrdMd_mmXzAi30m9MKocH2bHAb7Z6Cbpztd2V30RZFr_k-RjTD_U-RuW7WSIlCajC0fG96IhNq8yg6HvORVkyztyCpZH-RBlkVZNpQPjJq8znI2ZnlVCZGolmWsyHKe5XnR8CY98ImqZipK2eTDNA1QZHQRSqdaP19S6-ZEeb9RWzVNXSdaDKT97jTG3uzBoudcG9Mfhm32UGRa-eA_GwQVNLVfNRMyBHa8l1YZfHHWzLhqIQmB98nmdLuEsHrgR2A9sH5WYdmGVNoLsD6Ced8eVmd_kAzA-p2aB9bv7H4HAAD__xyoVgo">