Skip to content

Commit 6ec7538

Browse files
fix for checking on if RNG was init'd in test before free'ing it
1 parent d3f43c9 commit 6ec7538

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/wh_test_crypto.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3734,6 +3734,7 @@ int whTestCrypto_MlDsaVerifyOnlyDma(whClientContext* ctx, int devId,
37343734
int whTest_CryptoClientConfig(whClientConfig* config)
37353735
{
37363736
int i;
3737+
int rngInited = 0;
37373738
whClientContext client[1] = {0};
37383739
int ret = 0;
37393740
/* wolfcrypt */
@@ -3775,6 +3776,9 @@ int whTest_CryptoClientConfig(whClientConfig* config)
37753776
if (ret != 0) {
37763777
WH_ERROR_PRINT("Failed to reinitialize RNG %d\n", ret);
37773778
}
3779+
else {
3780+
rngInited = 1;
3781+
}
37783782
}
37793783

37803784
if (ret == 0) {
@@ -3935,7 +3939,9 @@ int whTest_CryptoClientConfig(whClientConfig* config)
39353939
#endif /* WOLFHSM_CFG_TEST_VERBOSE */
39363940

39373941
/* Clean up used resources */
3938-
(void)wc_FreeRng(rng);
3942+
if (rngInited) {
3943+
(void)wc_FreeRng(rng);
3944+
}
39393945
(void)wh_Client_CommClose(client);
39403946
(void)wh_Client_Cleanup(client);
39413947

0 commit comments

Comments
 (0)