Since there's no continuation, the ; can go as well :-)
[oweals/openssl.git] / crypto / asn1 / x_pubkey.c
index 55630294b65bac218e8082a02fb691ddd2627dcb..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;