fix memory leaks. from Dirk Engling
authortedu <tedu@openbsd.org>
Tue, 22 Apr 2014 20:31:57 +0000 (20:31 +0000)
committertedu <tedu@openbsd.org>
Tue, 22 Apr 2014 20:31:57 +0000 (20:31 +0000)
lib/libcrypto/asn1/f_enum.c
lib/libcrypto/asn1/f_int.c
lib/libcrypto/asn1/f_string.c
lib/libssl/src/crypto/asn1/f_enum.c
lib/libssl/src/crypto/asn1/f_int.c
lib/libssl/src/crypto/asn1/f_string.c

index 98fa312..5c42cdf 100644 (file)
@@ -158,8 +158,6 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
                        if (sp == NULL) {
                                ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,
                                    ERR_R_MALLOC_FAILURE);
-                               if (s != NULL)
-                                       free(s);
                                goto err;
                        }
                        s = sp;
@@ -191,12 +189,11 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
        }
        bs->length = num;
        bs->data = s;
-       ret = 1;
+       return (1);
 
-err:
-       if (0) {
 err_sl:
-               ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
-       }
+       ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
+err:
+       free(s);
        return (ret);
 }
index 3f671d1..41e0e75 100644 (file)
@@ -162,8 +162,6 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
                        if (sp == NULL) {
                                ASN1err(ASN1_F_A2I_ASN1_INTEGER,
                                    ERR_R_MALLOC_FAILURE);
-                               if (s != NULL)
-                                       free(s);
                                goto err;
                        }
                        s = sp;
@@ -195,12 +193,11 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
        }
        bs->length = num;
        bs->data = s;
-       ret = 1;
+       return (1);
 
-err:
-       if (0) {
 err_sl:
-               ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
-       }
+       ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
+err:
+       free(s);
        return (ret);
 }
index c213c7a..14f6554 100644 (file)
@@ -154,8 +154,6 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
                        if (sp == NULL) {
                                ASN1err(ASN1_F_A2I_ASN1_STRING,
                                    ERR_R_MALLOC_FAILURE);
-                               if (s != NULL)
-                                       free(s);
                                goto err;
                        }
                        s = sp;
@@ -187,12 +185,11 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
        }
        bs->length = num;
        bs->data = s;
-       ret = 1;
+       return (1);
 
-err:
-       if (0) {
 err_sl:
-               ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
-       }
+       ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
+err:
+       free(s);
        return (ret);
 }
index 98fa312..5c42cdf 100644 (file)
@@ -158,8 +158,6 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
                        if (sp == NULL) {
                                ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,
                                    ERR_R_MALLOC_FAILURE);
-                               if (s != NULL)
-                                       free(s);
                                goto err;
                        }
                        s = sp;
@@ -191,12 +189,11 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
        }
        bs->length = num;
        bs->data = s;
-       ret = 1;
+       return (1);
 
-err:
-       if (0) {
 err_sl:
-               ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
-       }
+       ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
+err:
+       free(s);
        return (ret);
 }
index 3f671d1..41e0e75 100644 (file)
@@ -162,8 +162,6 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
                        if (sp == NULL) {
                                ASN1err(ASN1_F_A2I_ASN1_INTEGER,
                                    ERR_R_MALLOC_FAILURE);
-                               if (s != NULL)
-                                       free(s);
                                goto err;
                        }
                        s = sp;
@@ -195,12 +193,11 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
        }
        bs->length = num;
        bs->data = s;
-       ret = 1;
+       return (1);
 
-err:
-       if (0) {
 err_sl:
-               ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
-       }
+       ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
+err:
+       free(s);
        return (ret);
 }
index c213c7a..14f6554 100644 (file)
@@ -154,8 +154,6 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
                        if (sp == NULL) {
                                ASN1err(ASN1_F_A2I_ASN1_STRING,
                                    ERR_R_MALLOC_FAILURE);
-                               if (s != NULL)
-                                       free(s);
                                goto err;
                        }
                        s = sp;
@@ -187,12 +185,11 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
        }
        bs->length = num;
        bs->data = s;
-       ret = 1;
+       return (1);
 
-err:
-       if (0) {
 err_sl:
-               ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
-       }
+       ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
+err:
+       free(s);
        return (ret);
 }