Accept NULL in *_free.
authorBen Laurie <ben@openssl.org>
Thu, 7 Jan 1999 19:15:59 +0000 (19:15 +0000)
committerBen Laurie <ben@openssl.org>
Thu, 7 Jan 1999 19:15:59 +0000 (19:15 +0000)
24 files changed:
CHANGES
crypto/asn1/p7_lib.c
crypto/asn1/x_name.c
crypto/bio/b_sock.c
crypto/bio/bss_acpt.c
crypto/bio/bss_conn.c
crypto/bn/bn_blind.c
crypto/bn/bn_lib.c
crypto/bn/bn_mont.c
crypto/bn/bn_recp.c
crypto/buffer/buffer.c
crypto/comp/comp_lib.c
crypto/err/err.c
crypto/rsa/rsa_eay.c
crypto/rsa/rsa_enc.c
crypto/txt_db/txt_db.c
crypto/x509/x509_lu.c
ssl/s2_lib.c
ssl/s3_enc.c
ssl/s3_lib.c
ssl/ssl_cert.c
ssl/ssl_comp.c
ssl/ssl_lib.c
ssl/ssl_sess.c

diff --git a/CHANGES b/CHANGES
index 882b247ba6398ae2dd6891ab4c337bce2ad65899..8bda119818dab87a48e7da9ed0d19c2d10cd2a37 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@
 
  Changes between 0.9.1c and 0.9.2
 
+  *) Make _all_ *_free functions accept a NULL pointer.
+     [Frans Heymans <fheymans@isaserver.be>]
+
   *) If a DH key is generated in s3_srvr.c, don't blow it by trying to use
      NULL pointers.
      [Anonymous <nobody@replay.com>]
index 06e1da4a742ca9f9df4ebb4bc5e08ceb862ed3f3..4ab64777b3ff4c2e2fc1fd9099943d71f3a3647a 100644 (file)
@@ -267,6 +267,9 @@ PKCS7 *a;
 void PKCS7_content_free(a)
 PKCS7 *a;
        {
+       if(a == NULL)
+           return;
+
        if (a->asn1 != NULL) Free((char *)a->asn1);
 
        if (a->d.ptr != NULL)
index 3b8bc5191f0ae07d8df46dab701f7ef319d58e29..3af14c8e6c1f91f72b871a600d89f30e00628b9b 100644 (file)
@@ -263,6 +263,9 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_new()
 void X509_NAME_free(a)
 X509_NAME *a;
        {
+       if(a == NULL)
+           return;
+
        BUF_MEM_free(a->bytes);
        sk_pop_free(a->entries,X509_NAME_ENTRY_free);
        Free((char *)a);
index 2c36150b9b038405bac5d852dbab92c777559ded..402439cc2ef156f0042e1be148abe478572c6183 100644 (file)
@@ -310,6 +310,9 @@ struct hostent *a;
        {
        int i;
 
+       if(a == NULL)
+           return;
+
        if (a->h_aliases != NULL)
                {
                for (i=0; a->h_aliases[i] != NULL; i++)
index 872807d8634da863fc748357c97bcd38760c78a6..ecdd1709d1779eaee7e5f43ad3aa3fea9b75b089 100644 (file)
@@ -173,6 +173,9 @@ BIO_ACCEPT *BIO_ACCEPT_new()
 void BIO_ACCEPT_free(a)
 BIO_ACCEPT *a;
        {
+       if(a == NULL)
+           return;
+
        if (a->param_addr != NULL) Free(a->param_addr);
        if (a->addr != NULL) Free(a->addr);
        if (a->bio_chain != NULL) BIO_free(a->bio_chain);
index 3ec1388f2e8ac8b5ea94f03b13b2362de3afb5a6..b90fea1a3a696df3280381b705b10c3d547da92b 100644 (file)
@@ -357,6 +357,9 @@ BIO_CONNECT *BIO_CONNECT_new()
 void BIO_CONNECT_free(a)
 BIO_CONNECT *a;
        {
+       if(a == NULL)
+           return;
+
        if (a->param_hostname != NULL)
                Free(a->param_hostname);
        if (a->param_port != NULL)
index 35be32b99a5e466bee2c68320b3f352add747cad..c247f71c8ae237f04e5c788428c3077092778dd0 100644 (file)
@@ -90,6 +90,9 @@ err:
 void BN_BLINDING_free(r)
 BN_BLINDING *r;
        {
+       if(r == NULL)
+           return;
+
        if (r->A  != NULL) BN_free(r->A );
        if (r->Ai != NULL) BN_free(r->Ai);
        Free(r);
index c027d0b03e250b9775f9beca9f01676f6b3acc47..d8d2c3297d828b198d1f215e14927908e65f9a23 100644 (file)
@@ -341,6 +341,9 @@ BN_CTX *c;
        {
        int i;
 
+       if(c == NULL)
+           return;
+
        for (i=0; i<BN_CTX_NUM; i++)
                BN_clear_free(&(c->bn[i]));
        if (c->flags & BN_FLG_MALLOCED)
index a5640b5a3b5b9a63bc83b5bf43e4191e7d578a54..2215dc3589c104dc51e8ed7e26cf200b13e27d07 100644 (file)
@@ -289,6 +289,9 @@ BN_MONT_CTX *ctx;
 void BN_MONT_CTX_free(mont)
 BN_MONT_CTX *mont;
        {
+       if(mont == NULL)
+           return;
+
        BN_free(&(mont->RR));
        BN_free(&(mont->N));
        BN_free(&(mont->Ni));
index 97ca857ed1b2463428b1504c79e248ecb1d65d5a..3ace566b552e4dc88168b5a55f25533526a0f114 100644 (file)
@@ -84,6 +84,9 @@ BN_RECP_CTX *BN_RECP_CTX_new()
 void BN_RECP_CTX_free(recp)
 BN_RECP_CTX *recp;
        {
+       if(recp == NULL)
+           return;
+
        BN_free(&(recp->N));
        BN_free(&(recp->Nr));
        if (recp->flags & BN_FLG_MALLOCED)
index 7e8af9e2fa367d11f56c2c82eadade457e30f2c3..b160a74a473c2d317fe846274804c0db922d0925 100644 (file)
@@ -79,6 +79,9 @@ BUF_MEM *BUF_MEM_new()
 void BUF_MEM_free(a)
 BUF_MEM *a;
        {
+       if(a == NULL)
+           return;
+
        if (a->data != NULL)
                {
                memset(a->data,0,(unsigned int)a->max);
index 8ce06951af1b4db34674571283ce426967158f91..dcacb5557d463d75fb34be8a67d5dc2c2f7794ff 100644 (file)
@@ -33,6 +33,9 @@ COMP_CTX *ctx;
        {
        /* CRYPTO_free_ex_data(rsa_meth,(char *)ctx,&ctx->ex_data); */
 
+       if(ctx == NULL)
+           return;
+
        if (ctx->meth->finish != NULL)
                ctx->meth->finish(ctx);
 
index 5cf621855acdb52aaa5f61e3657f48e537463867..39c997aef8932db263ae84ffb4c3861baff87433 100644 (file)
@@ -175,6 +175,9 @@ ERR_STATE *s;
        {
        int i;
 
+       if(s == NULL)
+           return;
+
        for (i=0; i<ERR_NUM_ERRORS; i++)
                {
                err_clear_data(s,i);
index ec143e873bbfa97626063fdfe8114d7a2b5b7b2f..b4050506c3680823711030c1b22664907740b9df 100644 (file)
@@ -474,8 +474,7 @@ RSA *rsa;
 err:
        BN_clear_free(&m1);
        BN_clear_free(&r1);
-       if(ctx)
-           BN_CTX_free(ctx);
+       BN_CTX_free(ctx);
        return(ret);
        }
 
index 5f91239da55a055c75ec81a9cbf39888a31153c7..c4a4ad5a605c81267b9c8560c2e651b181cd3efc 100644 (file)
@@ -531,8 +531,7 @@ RSA *rsa;
 err:
        if (m1 != NULL) BN_free(m1);
        if (r1 != NULL) BN_free(r1);
-       if(ctx != NULL)
-           BN_CTX_free(ctx);
+       BN_CTX_free(ctx);
        return(ret);
        }
 
index e4259d976853c61f27f17300a6001e9fa50e2558..dccb2b9513e3f1ee7970513a98ed98e0a9e1d54f 100644 (file)
@@ -356,6 +356,9 @@ TXT_DB *db;
        int i,n;
        char **p,*max;
 
+       if(db == NULL)
+           return;
+
        if (db->index != NULL)
                {
                for (i=db->num_fields-1; i>=0; i--)
index deec5adae5218895a18a08132bf9c990c7e8727c..8ea68198fc603a2bcfeefc92a44b0095d1449c52 100644 (file)
@@ -259,6 +259,9 @@ X509_STORE *vfy;
        STACK *sk;
        X509_LOOKUP *lu;
 
+       if(vfy == NULL)
+           return;
+
        sk=vfy->get_cert_methods;
        for (i=0; i<sk_num(sk); i++)
                {
index 51f686128f3ac476f48869a8f39e73e4f2cac67c..097c35ee68720625da993768296c592c061c100d 100644 (file)
@@ -257,6 +257,9 @@ SSL *s;
        {
        SSL2_CTX *s2;
 
+       if(s == NULL)
+           return;
+
        s2=s->s2;
        if (s2->rbuf != NULL) Free(s2->rbuf);
        if (s2->wbuf != NULL) Free(s2->wbuf);
index 116b09615524fc3b8db40347a0d788a0cc4a7015..ea8e39ef0662d9fd183828d2a5c61d4d2431efec 100644 (file)
@@ -208,6 +208,7 @@ int which;
 
        p=s->s3->tmp.key_block;
        i=EVP_MD_size(m);
+       // Should be    j=exp?min(5,EVP_CIPHER_key_length(c)):EVP_CIPHER_key_length(c); ?? - Ben 30/12/98
        j=(exp)?5:EVP_CIPHER_key_length(c);
        k=EVP_CIPHER_iv_length(c);
        if (    (which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) ||
index a523207a9f754c262797faba7373f6cb8c5b50f1..f15bb2438a64eb431c13e6f3fb8c37aeb80fd097 100644 (file)
@@ -456,6 +456,9 @@ err:
 void ssl3_free(s)
 SSL *s;
        {
+       if(s == NULL)
+           return;
+
        ssl3_cleanup_key_block(s);
        if (s->s3->rbuf.buf != NULL)
                Free(s->s3->rbuf.buf);
index 1bff91eaa8d2f89063ad06baeb57d3b83dd6877d..7d4531d808ec6ad7f32d38d61f58d9b9706f2326 100644 (file)
@@ -105,6 +105,9 @@ CERT *c;
        {
        int i;
 
+       if(c == NULL)
+           return;
+
        i=CRYPTO_add(&c->references,-1,CRYPTO_LOCK_SSL_CERT);
 #ifdef REF_PRINT
        REF_PRINT("CERT",c);
index 7724ff5672c7d646c39bda46202fa5724eb414c9..1593afb806d50dec25f5d480603894afee09ac7b 100644 (file)
@@ -361,6 +361,9 @@ SSL_SESSION *ss;
        {
        int i;
 
+       if(ss == NULL)
+           return;
+
        i=CRYPTO_add(&ss->references,-1,CRYPTO_LOCK_SSL_SESSION);
 #ifdef REF_PRINT
        REF_PRINT("SSL_SESSION",ss);
index e56233075ea38ea5679bb2a4eb853ad0ec8aad38..9e578fd738be8ff5d21a026fb44de3a93cf12d09 100644 (file)
@@ -203,6 +203,9 @@ SSL *s;
        {
        int i;
 
+       if(s == NULL)
+           return;
+
        i=CRYPTO_add(&s->references,-1,CRYPTO_LOCK_SSL);
 #ifdef REF_PRINT
        REF_PRINT("SSL",s);
index d4978a7d50a29a4c711827ab372212e1b40fa31e..95cd7fed8ad31170047144ff7ba84c918c4c3f5c 100644 (file)
@@ -363,6 +363,9 @@ SSL_SESSION *ss;
        {
        int i;
 
+       if(ss == NULL)
+           return;
+
        i=CRYPTO_add(&ss->references,-1,CRYPTO_LOCK_SSL_SESSION);
 #ifdef REF_PRINT
        REF_PRINT("SSL_SESSION",ss);