Skip to content

Commit 263cb5b

Browse files
committed
tests/api.c:test_Sha512_Family_Final(): fix unreachable null pointer deref reported by clang-tidy in FIPS/Async configs.
1 parent 072c531 commit 263cb5b

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

tests/api.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15007,14 +15007,20 @@ static int test_Sha512_Family_Final(int type, int isRaw)
1500715007
hash_test[2] = hash3;
1500815008
times = sizeof(hash_test) / sizeof(byte *);
1500915009

15010-
/* Good test args. */
15011-
for (i = 0; i < times; i++) {
15012-
ExpectIntEQ(finalFp(&sha512, hash_test[i]), 0);
15010+
#if defined(HAVE_FIPS) || defined(HAVE_SELFTEST) || \
15011+
defined(WOLFSSL_NO_HASH_RAW)
15012+
if (finalFp != NULL)
15013+
#endif
15014+
{
15015+
/* Good test args. */
15016+
for (i = 0; i < times; i++) {
15017+
ExpectIntEQ(finalFp(&sha512, hash_test[i]), 0);
15018+
}
15019+
/* Test bad args. */
15020+
ExpectIntEQ(finalFp(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
15021+
ExpectIntEQ(finalFp(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
15022+
ExpectIntEQ(finalFp(&sha512, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
1501315023
}
15014-
/* Test bad args. */
15015-
ExpectIntEQ(finalFp(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
15016-
ExpectIntEQ(finalFp(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
15017-
ExpectIntEQ(finalFp(&sha512, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
1501815024

1501915025
freeFp(&sha512);
1502015026

0 commit comments

Comments
 (0)