From cc684e330b61975a4c478e01a46ca687106eebbf Mon Sep 17 00:00:00 2001 From: Nils Larsch Date: Fri, 16 Feb 2007 20:34:15 +0000 Subject: ensure that the EVP_CIPHER_CTX object is initialized PR: 1490 --- ssl/s2_enc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ssl/s2_enc.c') diff --git a/ssl/s2_enc.c b/ssl/s2_enc.c index 18882bf704..1f62acd5b1 100644 --- a/ssl/s2_enc.c +++ b/ssl/s2_enc.c @@ -82,15 +82,18 @@ int ssl2_enc_init(SSL *s, int client) ((s->enc_read_ctx=(EVP_CIPHER_CTX *) OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) goto err; + + /* make sure it's intialized in case the malloc for enc_write_ctx fails + * and we exit with an error */ + rs= s->enc_read_ctx; + EVP_CIPHER_CTX_init(rs); + if ((s->enc_write_ctx == NULL) && ((s->enc_write_ctx=(EVP_CIPHER_CTX *) OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) goto err; - rs= s->enc_read_ctx; ws= s->enc_write_ctx; - - EVP_CIPHER_CTX_init(rs); EVP_CIPHER_CTX_init(ws); num=c->key_len; -- cgit v1.2.3