just like libc free(), asn1_string_free can cope with null. so don't
bother with polluting the callers with such tests.

Index: asn1/a_bytes.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/asn1/a_bytes.c,v
retrieving revision 1.14
diff -u -p -r1.14 a_bytes.c
--- asn1/a_bytes.c      12 Jun 2014 15:49:27 -0000      1.14
+++ asn1/a_bytes.c      9 Jul 2014 19:55:28 -0000
@@ -121,7 +121,7 @@ d2i_ASN1_type_bytes(ASN1_STRING **a, con
 
 err:
        ASN1err(ASN1_F_D2I_ASN1_TYPE_BYTES, i);
-       if ((ret != NULL) && ((a == NULL) || (*a != ret)))
+       if (a == NULL || *a != ret)
                ASN1_STRING_free(ret);
        return (NULL);
 }
@@ -230,7 +230,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const un
        return (ret);
 
 err:
-       if ((ret != NULL) && ((a == NULL) || (*a != ret)))
+       if (a == NULL || *a != ret)
                ASN1_STRING_free(ret);
        ASN1err(ASN1_F_D2I_ASN1_BYTES, i);
        return (NULL);
@@ -292,14 +292,12 @@ asn1_collate_primitive(ASN1_STRING *a, A
        a->length = num;
        free(a->data);
        a->data = (unsigned char *)b.data;
-       if (os != NULL)
-               ASN1_STRING_free(os);
+       ASN1_STRING_free(os);
        return (1);
 
 err:
        ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE, c->error);
-       if (os != NULL)
-               ASN1_STRING_free(os);
+       ASN1_STRING_free(os);
        free(b.data);
        return (0);
 }
Index: asn1/p5_pbe.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/asn1/p5_pbe.c,v
retrieving revision 1.13
diff -u -p -r1.13 p5_pbe.c
--- asn1/p5_pbe.c       12 Jun 2014 15:49:27 -0000      1.13
+++ asn1/p5_pbe.c       9 Jul 2014 19:55:29 -0000
@@ -119,8 +119,7 @@ PKCS5_pbe_set0_algor(X509_ALGOR *algor, 
 err:
        if (pbe != NULL)
                PBEPARAM_free(pbe);
-       if (pbe_str != NULL)
-               ASN1_STRING_free(pbe_str);
+       ASN1_STRING_free(pbe_str);
        return 0;
 }
 
Index: dh/dh_ameth.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/dh/dh_ameth.c,v
retrieving revision 1.9
diff -u -p -r1.9 dh_ameth.c
--- dh/dh_ameth.c       9 Jul 2014 13:26:47 -0000       1.9
+++ dh/dh_ameth.c       9 Jul 2014 19:55:29 -0000
@@ -167,8 +167,7 @@ dh_pub_encode(X509_PUBKEY *pk, const EVP
 
 err:
        free(penc);
-       if (str)
-               ASN1_STRING_free(str);
+       ASN1_STRING_free(str);
 
        return 0;
 }
@@ -271,10 +270,8 @@ dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, 
 
 err:
        free(dp);
-       if (params != NULL)
-               ASN1_STRING_free(params);
-       if (prkey != NULL)
-               ASN1_INTEGER_free(prkey);
+       ASN1_STRING_free(params);
+       ASN1_INTEGER_free(prkey);
        return 0;
 }
 
Index: dsa/dsa_ameth.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/dsa/dsa_ameth.c,v
retrieving revision 1.9
diff -u -p -r1.9 dsa_ameth.c
--- dsa/dsa_ameth.c     9 Jul 2014 10:16:24 -0000       1.9
+++ dsa/dsa_ameth.c     9 Jul 2014 19:55:29 -0000
@@ -164,8 +164,7 @@ dsa_pub_encode(X509_PUBKEY *pk, const EV
 
 err:
        free(penc);
-       if (pval)
-               ASN1_STRING_free(pval);
+       ASN1_STRING_free(pval);
 
        return 0;
 }
@@ -319,10 +318,8 @@ dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8,
 
 err:
        free(dp);
-       if (params != NULL)
-               ASN1_STRING_free(params);
-       if (prkey != NULL)
-               ASN1_INTEGER_free(prkey);
+       ASN1_STRING_free(params);
+       ASN1_INTEGER_free(prkey);
        return 0;
 }
 
Index: rsa/rsa_ameth.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/rsa/rsa_ameth.c,v
retrieving revision 1.7
diff -u -p -r1.7 rsa_ameth.c
--- rsa/rsa_ameth.c     9 Jul 2014 08:20:08 -0000       1.7
+++ rsa/rsa_ameth.c     9 Jul 2014 19:55:29 -0000
@@ -622,8 +622,7 @@ err:
                        X509_ALGOR_free(mgf1alg);
                if (pss)
                        RSA_PSS_PARAMS_free(pss);
-               if (os1)
-                       ASN1_STRING_free(os1);
+               ASN1_STRING_free(os1);
                return rv;
        }
        return 2;

Reply via email to