Since there's no continuation, the ; can go as well :-)
[oweals/openssl.git] / crypto / asn1 / x_pubkey.c
index c4a849aff1e5dd62dd8a753438290bcc86300861..d9585401206dc793b4823725a4d774eb55643d9d 100644 (file)
@@ -84,7 +84,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
        X509_PUBKEY *pk;
        X509_ALGOR *a;
        ASN1_OBJECT *o;
-       unsigned char *s,*p;
+       unsigned char *s,*p = NULL;
        int i;
 
        if (x == NULL) return(0);
@@ -119,7 +119,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
                dsa->write_params=0;
                ASN1_TYPE_free(a->parameter);
                i=i2d_DSAparams(dsa,NULL);
-               p=(unsigned char *)OPENSSL_malloc(i);
+               if ((p=(unsigned char *)OPENSSL_malloc(i)) == NULL) goto err;
                pp=p;
                i2d_DSAparams(dsa,&pp);
                a->parameter=ASN1_TYPE_new();
@@ -136,7 +136,11 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
                }
 
        if ((i=i2d_PublicKey(pkey,NULL)) <= 0) goto err;
-       if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL) goto err;
+       if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL)
+               {
+               X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE);
+               goto err;
+               }
        p=s;
        i2d_PublicKey(pkey,&p);
        if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err;
@@ -169,8 +173,8 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
        long j;
        int type;
        unsigned char *p;
-       const unsigned char *cp;
 #ifndef OPENSSL_NO_DSA
+       const unsigned char *cp;
        X509_ALGOR *a;
 #endif
 
@@ -198,7 +202,7 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
        a=key->algor;
        if (ret->type == EVP_PKEY_DSA)
                {
-               if (a->parameter->type == V_ASN1_SEQUENCE)
+               if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))
                        {
                        ret->pkey.dsa->write_params=0;
                        cp=p=a->parameter->value.sequence->data;