tor_cert_t *cert;
EVP_PKEY *pkey;
RSA *rsa;
- int length = i2d_X509(x509_cert, NULL), length2;
+ int length, length2;
unsigned char *cp;
+ if (!x509_cert)
+ return NULL;
+
+ length = i2d_X509(x509_cert, NULL);
cert = tor_malloc_zero(sizeof(tor_cert_t));
if (length <= 0) {
tor_free(cert);
}
newcert = tor_cert_new(x509);
if (!newcert) {
- X509_free(x509);
return NULL;
}
if (newcert->encoded_len != certificate_len ||
result->my_link_cert = tor_cert_new(X509_dup(cert));
result->my_id_cert = tor_cert_new(X509_dup(idcert));
result->my_auth_cert = tor_cert_new(X509_dup(authcert));
+ if (!result->my_link_cert || !result->my_id_cert || !result->my_auth_cert)
+ goto error;
result->link_key = crypto_pk_dup_key(rsa);
result->auth_key = crypto_pk_dup_key(rsa_auth);