diff --git a/wolfssl/test.h b/wolfssl/test.h index 926f1f73e..3a540041a 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -2970,8 +2970,9 @@ static WC_INLINE word16 GetRandomPort(void) /* Generate random port for testing */ WC_RNG rng; if (wc_InitRng(&rng) == 0) { - wc_RNG_GenerateBlock(&rng, (byte*)&port, sizeof(port)); - port |= 0xC000; /* Make sure its in the 49152 - 65535 range */ + if (wc_RNG_GenerateBlock(&rng, (byte*)&port, sizeof(port)) == 0) { + port |= 0xC000; /* Make sure its in the 49152 - 65535 range */ + } wc_FreeRng(&rng); } (void)rng; /* for WC_NO_RNG case */