secp256k1/src/tests.c: Properly handle sscanf return value

This pull request fixes a bug which allows the `sh` variable to be used uninitialized when sscanf returns EOF.

Signed-off-by: Mustapha Abiola <mustapha@trilemma.net>
This commit is contained in:
Mustapha Abiola 2019-07-14 17:02:58 +02:00
parent fa33017135
commit a11c76c59a
1 changed files with 1 additions and 1 deletions

View File

@ -5180,7 +5180,7 @@ int main(int argc, char **argv) {
const char* ch = argv[2]; const char* ch = argv[2];
while (pos < 16 && ch[0] != 0 && ch[1] != 0) { while (pos < 16 && ch[0] != 0 && ch[1] != 0) {
unsigned short sh; unsigned short sh;
if (sscanf(ch, "%2hx", &sh)) { if ((sscanf(ch, "%2hx", &sh)) == 1) {
seed16[pos] = sh; seed16[pos] = sh;
} else { } else {
break; break;