提交 0e04674e 编写于 作者: F Filipe DA SILVA 提交者: Rich Salz

RT4047: Set reference count earlier

Make sure it's valid very early.
Signed-off-by: NRich Salz <rsalz@openssl.org>
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 20ca916d
...@@ -70,11 +70,12 @@ X509_PKEY *X509_PKEY_new(void) ...@@ -70,11 +70,12 @@ X509_PKEY *X509_PKEY_new(void)
if (!ret) if (!ret)
goto err; goto err;
ret->references = 1;
ret->enc_algor = X509_ALGOR_new(); ret->enc_algor = X509_ALGOR_new();
ret->enc_pkey = ASN1_OCTET_STRING_new(); ret->enc_pkey = ASN1_OCTET_STRING_new();
if (!ret->enc_algor || !ret->enc_pkey) if (!ret->enc_algor || !ret->enc_pkey)
goto err; goto err;
ret->references = 1;
return ret; return ret;
err: err:
X509_PKEY_free(ret); X509_PKEY_free(ret);
......
...@@ -192,6 +192,7 @@ CERT *ssl_cert_dup(CERT *cert) ...@@ -192,6 +192,7 @@ CERT *ssl_cert_dup(CERT *cert)
return (NULL); return (NULL);
} }
ret->references = 1;
ret->key = &ret->pkeys[cert->key - cert->pkeys]; ret->key = &ret->pkeys[cert->key - cert->pkeys];
#ifndef OPENSSL_NO_RSA #ifndef OPENSSL_NO_RSA
...@@ -278,7 +279,6 @@ CERT *ssl_cert_dup(CERT *cert) ...@@ -278,7 +279,6 @@ CERT *ssl_cert_dup(CERT *cert)
} }
} }
ret->references = 1;
/* Configured sigalgs copied across */ /* Configured sigalgs copied across */
if (cert->conf_sigalgs) { if (cert->conf_sigalgs) {
ret->conf_sigalgs = OPENSSL_malloc(cert->conf_sigalgslen); ret->conf_sigalgs = OPENSSL_malloc(cert->conf_sigalgslen);
......
...@@ -286,6 +286,7 @@ SSL *SSL_new(SSL_CTX *ctx) ...@@ -286,6 +286,7 @@ SSL *SSL_new(SSL_CTX *ctx)
s->options = ctx->options; s->options = ctx->options;
s->mode = ctx->mode; s->mode = ctx->mode;
s->max_cert_list = ctx->max_cert_list; s->max_cert_list = ctx->max_cert_list;
s->references = 1;
/* /*
* Earlier library versions used to copy the pointer to the CERT, not * Earlier library versions used to copy the pointer to the CERT, not
...@@ -372,7 +373,6 @@ SSL *SSL_new(SSL_CTX *ctx) ...@@ -372,7 +373,6 @@ SSL *SSL_new(SSL_CTX *ctx)
if (!s->method->ssl_new(s)) if (!s->method->ssl_new(s))
goto err; goto err;
s->references = 1;
s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1; s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1;
if (!SSL_clear(s)) if (!SSL_clear(s))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册