I will be a minute reading this. The comment from the context at the
bottom of the diff has
me laughing and crying again...


On Tue, Apr 22, 2014 at 5:43 PM, Dirk Engling <[email protected]> wrote:
> remove M_ASN1_New_Malloc, M_ASN1_New, M_ASN1_New_Error marcos, they hide
> a malloc and are only used once
>
>
> Index: x_pkey.c
> ===================================================================
> RCS file: /cvs/src/lib/libssl/src/crypto/asn1/x_pkey.c,v
> retrieving revision 1.10
> diff -u -r1.10 x_pkey.c
> --- x_pkey.c    18 Apr 2014 11:20:32 -0000      1.10
> +++ x_pkey.c    22 Apr 2014 23:43:03 -0000
> @@ -109,10 +109,18 @@
>         X509_PKEY *ret = NULL;
>         ASN1_CTX c;
>
> -       M_ASN1_New_Malloc(ret, X509_PKEY);
> +       if ((ret = malloc(sizeof(X509_PKEY))) == NULL )
> +               ASN1_MAC_H_err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE,
> +                       __LINE__ );
> +               return NULL;
> +       }
>         ret->version = 0;
> -       M_ASN1_New(ret->enc_algor, X509_ALGOR_new);
> -       M_ASN1_New(ret->enc_pkey, M_ASN1_OCTET_STRING_new);
> +       ret->enc_algor = X509_ALGOR_new();
> +       if (ret->enc_algor == NULL)
> +               return NULL;
> +       ret->enc_pkey = M_ASN1_OCTET_STRING_new();
> +       if (ret->enc_pkey == NULL)
> +               return NULL;
>         ret->dec_pkey = NULL;
>         ret->key_length = 0;
>         ret->key_data = NULL;
> @@ -121,7 +129,6 @@
>         memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
>         ret->references = 1;
>         return (ret);
> -       M_ASN1_New_Error(ASN1_F_X509_PKEY_NEW);
>  }
>
>  void
> Index: asn1_mac.h
> ===================================================================
> RCS file: /cvs/src/lib/libssl/src/crypto/asn1/asn1_mac.h,v
> retrieving revision 1.10
> diff -u -r1.10 asn1_mac.h
> --- asn1_mac.h  17 Apr 2014 13:37:48 -0000      1.10
> +++ asn1_mac.h  22 Apr 2014 23:43:03 -0000
> @@ -287,21 +287,6 @@
>                 c.slen-=(c.p-c.q); \
>                 }
>
> -/* New macros */
> -#define M_ASN1_New_Malloc(ret,type) \
> -       if ((ret=(type *)malloc(sizeof(type))) == NULL) \
> -               { c.line=__LINE__; goto err2; }
> -
> -#define M_ASN1_New(arg,func) \
> -       if (((arg)=func()) == NULL) return(NULL)
> -
> -#define M_ASN1_New_Error(a) \
> -/*     err:    ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
> -               return(NULL);*/ \
> -       err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
> -               return(NULL)
> -
> -
>  /* BIG UGLY WARNING!  This is so damn ugly I wanna puke.  Unfortunately,
>     some macros that use ASN1_const_CTX still insist on writing in the input
>     stream.  ARGH!  ARGH!  ARGH!  Let's get rid of this macro package.
>

Reply via email to