提交 0dfb9398 编写于 作者: R Rich Salz

free NULL cleanup

Start ensuring all OpenSSL "free" routines allow NULL, and remove
any if check before calling them.
This gets ASN1_OBJECT_free and ASN1_STRING_free.
Reviewed-by: NMatt Caswell <matt@openssl.org>
上级 7c82e339
...@@ -71,6 +71,11 @@ ...@@ -71,6 +71,11 @@
Remove all but one '#ifdef undef' which is to be looked at. Remove all but one '#ifdef undef' which is to be looked at.
[Rich Salz] [Rich Salz]
*) Clean up calling of xxx_free routines.
Just like free(), fix most of the xxx_free routines to accept
NULL. Remove the non-null checks from callers. Save much code.
[Rich Salz]
*) Experimental support for a new, fast, unbiased prime candidate generator, *) Experimental support for a new, fast, unbiased prime candidate generator,
bn_probable_prime_dh_coprime(). Not currently used by any prime generator. bn_probable_prime_dh_coprime(). Not currently used by any prime generator.
[Felix Laurie von Massenbach <felix@erbridge.co.uk>] [Felix Laurie von Massenbach <felix@erbridge.co.uk>]
......
...@@ -1152,7 +1152,6 @@ int MAIN(int argc, char **argv) ...@@ -1152,7 +1152,6 @@ int MAIN(int argc, char **argv)
OPENSSL_free(secret_keyid); OPENSSL_free(secret_keyid);
if (pwri_tmp) if (pwri_tmp)
OPENSSL_free(pwri_tmp); OPENSSL_free(pwri_tmp);
if (econtent_type)
ASN1_OBJECT_free(econtent_type); ASN1_OBJECT_free(econtent_type);
if (rr) if (rr)
CMS_ReceiptRequest_free(rr); CMS_ReceiptRequest_free(rr);
......
...@@ -177,7 +177,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, ...@@ -177,7 +177,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
return (ret); return (ret);
err: err:
ASN1err(ASN1_F_C2I_ASN1_BIT_STRING, i); ASN1err(ASN1_F_C2I_ASN1_BIT_STRING, i);
if ((ret != NULL) && ((a == NULL) || (*a != ret))) if ((a == NULL) || (*a != ret))
ASN1_BIT_STRING_free(ret); ASN1_BIT_STRING_free(ret);
return (NULL); return (NULL);
} }
......
...@@ -265,7 +265,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, ...@@ -265,7 +265,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
return (ret); return (ret);
err: err:
ASN1err(ASN1_F_C2I_ASN1_INTEGER, i); ASN1err(ASN1_F_C2I_ASN1_INTEGER, i);
if ((ret != NULL) && ((a == NULL) || (*a != ret))) if ((a == NULL) || (*a != ret))
ASN1_INTEGER_free(ret); ASN1_INTEGER_free(ret);
return (NULL); return (NULL);
} }
...@@ -334,7 +334,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, ...@@ -334,7 +334,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
return (ret); return (ret);
err: err:
ASN1err(ASN1_F_D2I_ASN1_UINTEGER, i); ASN1err(ASN1_F_D2I_ASN1_UINTEGER, i);
if ((ret != NULL) && ((a == NULL) || (*a != ret))) if ((a == NULL) || (*a != ret))
ASN1_INTEGER_free(ret); ASN1_INTEGER_free(ret);
return (NULL); return (NULL);
} }
......
...@@ -193,11 +193,11 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, ...@@ -193,11 +193,11 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
int free_s = 0; int free_s = 0;
if (s == NULL) { if (s == NULL) {
free_s = 1;
s = ASN1_UTCTIME_new(); s = ASN1_UTCTIME_new();
}
if (s == NULL) if (s == NULL)
goto err; goto err;
free_s = 1;
}
ts = OPENSSL_gmtime(&t, &data); ts = OPENSSL_gmtime(&t, &data);
if (ts == NULL) if (ts == NULL)
...@@ -233,7 +233,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, ...@@ -233,7 +233,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
#endif #endif
return (s); return (s);
err: err:
if (free_s && s) if (free_s)
ASN1_UTCTIME_free(s); ASN1_UTCTIME_free(s);
return NULL; return NULL;
} }
......
...@@ -429,7 +429,9 @@ void ASN1_STRING_free(ASN1_STRING *a) ...@@ -429,7 +429,9 @@ void ASN1_STRING_free(ASN1_STRING *a)
void ASN1_STRING_clear_free(ASN1_STRING *a) void ASN1_STRING_clear_free(ASN1_STRING *a)
{ {
if (a && a->data && !(a->flags & ASN1_STRING_FLAG_NDEF)) if (a == NULL)
return;
if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF))
OPENSSL_cleanse(a->data, a->length); OPENSSL_cleanse(a->data, a->length);
ASN1_STRING_free(a); ASN1_STRING_free(a);
} }
......
...@@ -276,10 +276,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, ...@@ -276,10 +276,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
nl = 1; nl = 1;
} }
} }
if (os != NULL) {
ASN1_OCTET_STRING_free(os); ASN1_OCTET_STRING_free(os);
os = NULL; os = NULL;
}
} else if (tag == V_ASN1_INTEGER) { } else if (tag == V_ASN1_INTEGER) {
ASN1_INTEGER *bs; ASN1_INTEGER *bs;
int i; int i;
...@@ -356,9 +354,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, ...@@ -356,9 +354,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
} }
ret = 1; ret = 1;
end: end:
if (o != NULL)
ASN1_OBJECT_free(o); ASN1_OBJECT_free(o);
if (os != NULL)
ASN1_OCTET_STRING_free(os); ASN1_OCTET_STRING_free(os);
*pp = p; *pp = p;
return (ret); return (ret);
......
...@@ -187,7 +187,6 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, ...@@ -187,7 +187,6 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,
err: err:
ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, ASN1_R_DATA_IS_WRONG); ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, ASN1_R_DATA_IS_WRONG);
} }
if (os != NULL)
ASN1_OCTET_STRING_free(os); ASN1_OCTET_STRING_free(os);
if (ai != NULL) if (ai != NULL)
ASN1_INTEGER_free(ai); ASN1_INTEGER_free(ai);
......
...@@ -118,7 +118,6 @@ int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, ...@@ -118,7 +118,6 @@ int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
err: err:
if (pbe != NULL) if (pbe != NULL)
PBEPARAM_free(pbe); PBEPARAM_free(pbe);
if (pbe_str != NULL)
ASN1_STRING_free(pbe_str); ASN1_STRING_free(pbe_str);
return 0; return 0;
} }
......
...@@ -85,6 +85,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, ...@@ -85,6 +85,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
const ASN1_AUX *aux = it->funcs; const ASN1_AUX *aux = it->funcs;
ASN1_aux_cb *asn1_cb; ASN1_aux_cb *asn1_cb;
int i; int i;
if (!pval) if (!pval)
return; return;
if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
...@@ -116,6 +117,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, ...@@ -116,6 +117,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
i = asn1_get_choice_selector(pval, it); i = asn1_get_choice_selector(pval, it);
if ((i >= 0) && (i < it->tcount)) { if ((i >= 0) && (i < it->tcount)) {
ASN1_VALUE **pchval; ASN1_VALUE **pchval;
tt = it->templates + i; tt = it->templates + i;
pchval = asn1_get_field_ptr(pval, tt); pchval = asn1_get_field_ptr(pval, tt);
ASN1_template_free(pchval, tt); ASN1_template_free(pchval, tt);
...@@ -170,35 +172,41 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, ...@@ -170,35 +172,41 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
{ {
int i;
if (tt->flags & ASN1_TFLG_SK_MASK) { if (tt->flags & ASN1_TFLG_SK_MASK) {
STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval; STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
int i;
for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) { for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
ASN1_VALUE *vtmp; ASN1_VALUE *vtmp = sk_ASN1_VALUE_value(sk, i);
vtmp = sk_ASN1_VALUE_value(sk, i);
asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item), 0); asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item), 0);
} }
sk_ASN1_VALUE_free(sk); sk_ASN1_VALUE_free(sk);
*pval = NULL; *pval = NULL;
} else } else {
asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item), asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item),
tt->flags & ASN1_TFLG_COMBINE); tt->flags & ASN1_TFLG_COMBINE);
}
} }
void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
{ {
int utype; int utype;
/* Special case: if 'it' is a primitive with a free_func, use that. */
if (it) { if (it) {
const ASN1_PRIMITIVE_FUNCS *pf; const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
pf = it->funcs;
if (pf && pf->prim_free) { if (pf && pf->prim_free) {
pf->prim_free(pval, it); pf->prim_free(pval, it);
return; return;
} }
} }
/* Special case: if 'it' is NULL free contents of ASN1_TYPE */
/* Special case: if 'it' is NULL, free contents of ASN1_TYPE */
if (!it) { if (!it) {
ASN1_TYPE *typ = (ASN1_TYPE *)*pval; ASN1_TYPE *typ = (ASN1_TYPE *)*pval;
utype = typ->type; utype = typ->type;
pval = &typ->value.asn1_value; pval = &typ->value.asn1_value;
if (!*pval) if (!*pval)
...@@ -235,8 +243,8 @@ void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) ...@@ -235,8 +243,8 @@ void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
default: default:
ASN1_STRING_free((ASN1_STRING *)*pval); ASN1_STRING_free((ASN1_STRING *)*pval);
*pval = NULL;
break; break;
} }
if (*pval)
*pval = NULL; *pval = NULL;
} }
...@@ -86,7 +86,6 @@ int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) ...@@ -86,7 +86,6 @@ int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval)
return 0; return 0;
} }
if (alg) { if (alg) {
if (alg->algorithm)
ASN1_OBJECT_free(alg->algorithm); ASN1_OBJECT_free(alg->algorithm);
alg->algorithm = aobj; alg->algorithm = aobj;
} }
......
...@@ -143,7 +143,6 @@ void X509_PKEY_free(X509_PKEY *x) ...@@ -143,7 +143,6 @@ void X509_PKEY_free(X509_PKEY *x)
if (x->enc_algor != NULL) if (x->enc_algor != NULL)
X509_ALGOR_free(x->enc_algor); X509_ALGOR_free(x->enc_algor);
if (x->enc_pkey != NULL)
ASN1_OCTET_STRING_free(x->enc_pkey); ASN1_OCTET_STRING_free(x->enc_pkey);
if (x->dec_pkey != NULL) if (x->dec_pkey != NULL)
EVP_PKEY_free(x->dec_pkey); EVP_PKEY_free(x->dec_pkey);
......
...@@ -159,7 +159,6 @@ int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj) ...@@ -159,7 +159,6 @@ int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
if (!objtmp || sk_ASN1_OBJECT_push(aux->trust, objtmp)) if (!objtmp || sk_ASN1_OBJECT_push(aux->trust, objtmp))
return 1; return 1;
err: err:
if (objtmp)
ASN1_OBJECT_free(objtmp); ASN1_OBJECT_free(objtmp);
return 0; return 0;
} }
......
...@@ -191,7 +191,6 @@ static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) ...@@ -191,7 +191,6 @@ static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
err: err:
if (penc) if (penc)
OPENSSL_free(penc); OPENSSL_free(penc);
if (str)
ASN1_STRING_free(str); ASN1_STRING_free(str);
return 0; return 0;
...@@ -297,7 +296,6 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) ...@@ -297,7 +296,6 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
err: err:
if (dp != NULL) if (dp != NULL)
OPENSSL_free(dp); OPENSSL_free(dp);
if (params != NULL)
ASN1_STRING_free(params); ASN1_STRING_free(params);
if (prkey != NULL) if (prkey != NULL)
ASN1_STRING_clear_free(prkey); ASN1_STRING_clear_free(prkey);
......
...@@ -155,7 +155,6 @@ static void pkey_dh_cleanup(EVP_PKEY_CTX *ctx) ...@@ -155,7 +155,6 @@ static void pkey_dh_cleanup(EVP_PKEY_CTX *ctx)
if (dctx) { if (dctx) {
if (dctx->kdf_ukm) if (dctx->kdf_ukm)
OPENSSL_free(dctx->kdf_ukm); OPENSSL_free(dctx->kdf_ukm);
if (dctx->kdf_oid)
ASN1_OBJECT_free(dctx->kdf_oid); ASN1_OBJECT_free(dctx->kdf_oid);
OPENSSL_free(dctx); OPENSSL_free(dctx);
} }
...@@ -245,7 +244,6 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) ...@@ -245,7 +244,6 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
return dctx->kdf_ukmlen; return dctx->kdf_ukmlen;
case EVP_PKEY_CTRL_DH_KDF_OID: case EVP_PKEY_CTRL_DH_KDF_OID:
if (dctx->kdf_oid)
ASN1_OBJECT_free(dctx->kdf_oid); ASN1_OBJECT_free(dctx->kdf_oid);
dctx->kdf_oid = p2; dctx->kdf_oid = p2;
return 1; return 1;
......
...@@ -166,7 +166,6 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) ...@@ -166,7 +166,6 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
err: err:
if (penc) if (penc)
OPENSSL_free(penc); OPENSSL_free(penc);
if (str)
ASN1_STRING_free(str); ASN1_STRING_free(str);
return 0; return 0;
...@@ -328,7 +327,6 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) ...@@ -328,7 +327,6 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
err: err:
if (dp != NULL) if (dp != NULL)
OPENSSL_free(dp); OPENSSL_free(dp);
if (params != NULL)
ASN1_STRING_free(params); ASN1_STRING_free(params);
if (prkey != NULL) if (prkey != NULL)
ASN1_STRING_clear_free(prkey); ASN1_STRING_clear_free(prkey);
......
...@@ -317,7 +317,6 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) ...@@ -317,7 +317,6 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
return 0; return 0;
/* clear the old values (if necessary) */ /* clear the old values (if necessary) */
if (field->fieldType != NULL)
ASN1_OBJECT_free(field->fieldType); ASN1_OBJECT_free(field->fieldType);
if (field->p.other != NULL) if (field->p.other != NULL)
ASN1_TYPE_free(field->p.other); ASN1_TYPE_free(field->p.other);
...@@ -654,7 +653,7 @@ ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *group, ...@@ -654,7 +653,7 @@ ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *group,
return NULL; return NULL;
} }
} else { } else {
if (ret->type == 0 && ret->value.named_curve) if (ret->type == 0)
ASN1_OBJECT_free(ret->value.named_curve); ASN1_OBJECT_free(ret->value.named_curve);
else if (ret->type == 1 && ret->value.parameters) else if (ret->type == 1 && ret->value.parameters)
ECPARAMETERS_free(ret->value.parameters); ECPARAMETERS_free(ret->value.parameters);
......
...@@ -110,7 +110,6 @@ OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, ...@@ -110,7 +110,6 @@ OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
goto err; goto err;
alg = cid->hashAlgorithm; alg = cid->hashAlgorithm;
if (alg->algorithm != NULL)
ASN1_OBJECT_free(alg->algorithm); ASN1_OBJECT_free(alg->algorithm);
if ((nid = EVP_MD_type(dgst)) == NID_undef) { if ((nid = EVP_MD_type(dgst)) == NID_undef) {
OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_UNKNOWN_NID); OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_UNKNOWN_NID);
......
...@@ -247,7 +247,7 @@ static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length) ...@@ -247,7 +247,7 @@ static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length)
return os; return os;
err: err:
if (os && (!pos || (*pos != os))) if ((pos == NULL) || (*pos != os))
ASN1_OCTET_STRING_free(os); ASN1_OCTET_STRING_free(os);
OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE);
return NULL; return NULL;
......
...@@ -484,7 +484,6 @@ static int rsa_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md) ...@@ -484,7 +484,6 @@ static int rsa_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md)
X509_ALGOR_set0(*palg, OBJ_nid2obj(NID_mgf1), V_ASN1_SEQUENCE, stmp); X509_ALGOR_set0(*palg, OBJ_nid2obj(NID_mgf1), V_ASN1_SEQUENCE, stmp);
stmp = NULL; stmp = NULL;
err: err:
if (stmp)
ASN1_STRING_free(stmp); ASN1_STRING_free(stmp);
if (algtmp) if (algtmp)
X509_ALGOR_free(algtmp); X509_ALGOR_free(algtmp);
...@@ -576,7 +575,6 @@ static ASN1_STRING *rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx) ...@@ -576,7 +575,6 @@ static ASN1_STRING *rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx)
RSA_PSS_PARAMS_free(pss); RSA_PSS_PARAMS_free(pss);
if (rv) if (rv)
return os; return os;
if (os)
ASN1_STRING_free(os); ASN1_STRING_free(os);
return NULL; return NULL;
} }
...@@ -921,7 +919,6 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri) ...@@ -921,7 +919,6 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
err: err:
if (oaep) if (oaep)
RSA_OAEP_PARAMS_free(oaep); RSA_OAEP_PARAMS_free(oaep);
if (os)
ASN1_STRING_free(os); ASN1_STRING_free(os);
return rv; return rv;
} }
......
...@@ -138,7 +138,6 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype, ...@@ -138,7 +138,6 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype,
} else } else
ret = 1; ret = 1;
err: err:
if (sig != NULL)
ASN1_OCTET_STRING_free(sig); ASN1_OCTET_STRING_free(sig);
if (s != NULL) { if (s != NULL) {
OPENSSL_cleanse(s, (unsigned int)siglen); OPENSSL_cleanse(s, (unsigned int)siglen);
......
...@@ -102,7 +102,6 @@ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, ...@@ -102,7 +102,6 @@ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy,
ret->expected_policy_set = sk_ASN1_OBJECT_new_null(); ret->expected_policy_set = sk_ASN1_OBJECT_new_null();
if (!ret->expected_policy_set) { if (!ret->expected_policy_set) {
OPENSSL_free(ret); OPENSSL_free(ret);
if (id)
ASN1_OBJECT_free(id); ASN1_OBJECT_free(id);
return NULL; return NULL;
} }
......
...@@ -212,7 +212,6 @@ static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, ...@@ -212,7 +212,6 @@ static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method,
X509V3err(X509V3_F_DO_EXT_I2D, ERR_R_MALLOC_FAILURE); X509V3err(X509V3_F_DO_EXT_I2D, ERR_R_MALLOC_FAILURE);
if (ext_der != NULL) if (ext_der != NULL)
OPENSSL_free(ext_der); OPENSSL_free(ext_der);
if (ext_oct != NULL)
ASN1_OCTET_STRING_free(ext_oct); ASN1_OCTET_STRING_free(ext_oct);
return NULL; return NULL;
......
...@@ -305,10 +305,7 @@ static PROXY_CERT_INFO_EXTENSION *r2i_pci(X509V3_EXT_METHOD *method, ...@@ -305,10 +305,7 @@ static PROXY_CERT_INFO_EXTENSION *r2i_pci(X509V3_EXT_METHOD *method,
pathlen = NULL; pathlen = NULL;
goto end; goto end;
err: err:
if (language) {
ASN1_OBJECT_free(language); ASN1_OBJECT_free(language);
language = NULL;
}
if (pathlen) { if (pathlen) {
ASN1_INTEGER_free(pathlen); ASN1_INTEGER_free(pathlen);
pathlen = NULL; pathlen = NULL;
......
...@@ -19,6 +19,7 @@ ASN1_OBJECT structure, which represents an ASN1 OBJECT IDENTIFIER. ...@@ -19,6 +19,7 @@ ASN1_OBJECT structure, which represents an ASN1 OBJECT IDENTIFIER.
ASN1_OBJECT_new() allocates and initializes a ASN1_OBJECT structure. ASN1_OBJECT_new() allocates and initializes a ASN1_OBJECT structure.
ASN1_OBJECT_free() frees up the B<ASN1_OBJECT> structure B<a>. ASN1_OBJECT_free() frees up the B<ASN1_OBJECT> structure B<a>.
If B<a> is NULL, nothing is done.
=head1 NOTES =head1 NOTES
......
...@@ -22,6 +22,7 @@ ASN1_STRING_type_new() returns an allocated B<ASN1_STRING> structure of ...@@ -22,6 +22,7 @@ ASN1_STRING_type_new() returns an allocated B<ASN1_STRING> structure of
type B<type>. type B<type>.
ASN1_STRING_free() frees up B<a>. ASN1_STRING_free() frees up B<a>.
If B<a> is NULL nothing is done.
=head1 NOTES =head1 NOTES
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册