Remove unnecessary frees and style fixes.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 6 Jan 2017 17:51:28 +0000 (17:51 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sun, 8 Jan 2017 01:42:52 +0000 (01:42 +0000)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2177)

crypto/rsa/rsa_ameth.c
crypto/rsa/rsa_pmeth.c

index 07002033fe5e45441658bfa517891d70b958be32..26033286e7119c138fa37dd2c0a9700e41102399 100644 (file)
@@ -44,11 +44,8 @@ static int rsa_param_encode(const EVP_PKEY *pkey,
         return 1;
     }
     /* Encode PSS parameters */
         return 1;
     }
     /* Encode PSS parameters */
-    if (!ASN1_item_pack(rsa->pss, ASN1_ITEM_rptr(RSA_PSS_PARAMS), pstr)) {
-        ASN1_STRING_free(*pstr);
-        *pstr = NULL;
+    if (ASN1_item_pack(rsa->pss, ASN1_ITEM_rptr(RSA_PSS_PARAMS), pstr) == NULL)
         return 0;
         return 0;
-    }
 
     *pstrtype = V_ASN1_SEQUENCE;
     return 1;
 
     *pstrtype = V_ASN1_SEQUENCE;
     return 1;
@@ -493,7 +490,7 @@ static int rsa_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md)
     /* need to embed algorithm ID inside another */
     if (!rsa_md_to_algor(&algtmp, mgf1md))
         goto err;
     /* need to embed algorithm ID inside another */
     if (!rsa_md_to_algor(&algtmp, mgf1md))
         goto err;
-    if (!ASN1_item_pack(algtmp, ASN1_ITEM_rptr(X509_ALGOR), &stmp))
+    if (ASN1_item_pack(algtmp, ASN1_ITEM_rptr(X509_ALGOR), &stmp) == NULL)
          goto err;
     *palg = X509_ALGOR_new();
     if (*palg == NULL)
          goto err;
     *palg = X509_ALGOR_new();
     if (*palg == NULL)
@@ -578,15 +575,12 @@ RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd,
 static ASN1_STRING *rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkctx)
 {
     RSA_PSS_PARAMS *pss = rsa_ctx_to_pss(pkctx);
 static ASN1_STRING *rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkctx)
 {
     RSA_PSS_PARAMS *pss = rsa_ctx_to_pss(pkctx);
-    ASN1_STRING *os = NULL;
+    ASN1_STRING *os;
 
     if (pss == NULL)
         return NULL;
 
 
     if (pss == NULL)
         return NULL;
 
-    if (!ASN1_item_pack(pss, ASN1_ITEM_rptr(RSA_PSS_PARAMS), &os)) {
-        ASN1_STRING_free(os);
-        os = NULL;
-    }
+    os = ASN1_item_pack(pss, ASN1_ITEM_rptr(RSA_PSS_PARAMS), NULL);
     RSA_PSS_PARAMS_free(pss);
     return os;
 }
     RSA_PSS_PARAMS_free(pss);
     return os;
 }
index 55f1f28d38fd53baa2837735aaf77a10552999c2..3e8f92c706173f75cd3dd4bb1cc24cf9d1b802f7 100644 (file)
@@ -50,6 +50,7 @@ typedef struct {
 static int pkey_rsa_init(EVP_PKEY_CTX *ctx)
 {
     RSA_PKEY_CTX *rctx = OPENSSL_zalloc(sizeof(*rctx));
 static int pkey_rsa_init(EVP_PKEY_CTX *ctx)
 {
     RSA_PKEY_CTX *rctx = OPENSSL_zalloc(sizeof(*rctx));
+
     if (rctx == NULL)
         return 0;
     rctx->nbits = 1024;
     if (rctx == NULL)
         return 0;
     rctx->nbits = 1024;