diff options
author | Matt Caswell <matt@openssl.org> | 2014-12-12 11:05:21 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2014-12-13 00:06:10 +0000 |
commit | eae2bb2f1f5347c0bd305026fd3c222e0ccd69e2 (patch) | |
tree | aadce1168371a109037913b65237ac05831f4c98 /ssl | |
parent | c3132708368e4d13ddfc74be225a979d16a6a37e (diff) |
Fix memory leak in s2_srvr.c if BUF_MEM_grow fails
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit d04a1e0b5beb3329cdf8c4ec35b9113cbc41d2f2)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/s2_srvr.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/ssl/s2_srvr.c b/ssl/s2_srvr.c index bc885e8e7f..73a54dc157 100644 --- a/ssl/s2_srvr.c +++ b/ssl/s2_srvr.c @@ -188,13 +188,21 @@ int ssl2_accept(SSL *s) s->version=SSL2_VERSION; s->type=SSL_ST_ACCEPT; - buf=s->init_buf; - if ((buf == NULL) && ((buf=BUF_MEM_new()) == NULL)) - { ret= -1; goto end; } - if (!BUF_MEM_grow(buf,(int) - SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) - { ret= -1; goto end; } - s->init_buf=buf; + if(s->init_buf == NULL) + { + if ((buf=BUF_MEM_new()) == NULL) + { + ret= -1; + goto end; + } + if (!BUF_MEM_grow(buf,(int) SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) + { + BUF_MEM_free(buf); + ret= -1; + goto end; + } + s->init_buf=buf; + } s->init_num=0; s->ctx->stats.sess_accept++; s->handshake_func=ssl2_accept; |