Merge branch 'refs/heads/t/openssl-header-check'
[paraslash.git] / openssl.c
index 7d5bb25d53cf73009803fe0e62ca15d0167a05cb..d11b1049d2a321905ab79ce2af6c1e86fe7b7991 100644 (file)
--- a/openssl.c
+++ b/openssl.c
@@ -57,7 +57,9 @@ void crypt_init(void)
 
 void crypt_shutdown(void)
 {
+#ifdef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA
        CRYPTO_cleanup_all_ex_data();
+#endif
 }
 
 static int get_private_key(const char *path, RSA **rsa)
@@ -124,11 +126,11 @@ static int read_rsa_bignums(const unsigned char *blob, int blen, RSA **result)
                return -E_BIGNUM;
        ret = read_bignum(p, end - p, &e);
        if (ret < 0)
-               goto fail;
+               goto free_rsa;
        p += ret;
        ret = read_bignum(p, end - p, &n);
        if (ret < 0)
-               goto fail;
+               goto free_e;
 #ifdef HAVE_RSA_SET0_KEY
        RSA_set0_key(rsa, n, e, NULL);
 #else
@@ -137,7 +139,9 @@ static int read_rsa_bignums(const unsigned char *blob, int blen, RSA **result)
 #endif
        *result = rsa;
        return 1;
-fail:
+free_e:
+       BN_free(e);
+free_rsa:
        RSA_free(rsa);
        return ret;
 }