test: fix coverity 1414449 & 1414471: resource leak

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14596)
This commit is contained in:
Pauli 2021-03-18 10:45:35 +10:00
parent c0cd48fcb9
commit 65bf029d49

View File

@ -208,12 +208,14 @@ static int test_lib(void)
fprintf(stderr, "Failed to close libcrypto\n"); fprintf(stderr, "Failed to close libcrypto\n");
goto end; goto end;
} }
cryptolib = SD_INIT;
if (test_type == CRYPTO_FIRST || test_type == SSL_FIRST) { if (test_type == CRYPTO_FIRST || test_type == SSL_FIRST) {
if (!sd_close(ssllib)) { if (!sd_close(ssllib)) {
fprintf(stderr, "Failed to close libssl\n"); fprintf(stderr, "Failed to close libssl\n");
goto end; goto end;
} }
ssllib = SD_INIT;
} }
# if defined(OPENSSL_NO_PINSHARED) \ # if defined(OPENSSL_NO_PINSHARED) \
@ -235,6 +237,10 @@ static int test_lib(void)
result = 1; result = 1;
end: end:
if (cryptolib != SD_INIT)
sd_close(cryptolib);
if (ssllib != SD_INIT)
sd_close(ssllib);
return result; return result;
} }
#endif #endif