diff options
author | FdaSilvaYY <fdasilvayy@gmail.com> | 2017-12-08 10:49:41 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-12-08 10:49:41 -0500 |
commit | a0fda2cf2dac8bc0d309261b3aaf4027a188b08c (patch) | |
tree | cdb682c910f5ae4825b1e3686facb1073f35c56d /crypto/bio | |
parent | cef115ff0ca4255d3decc1dda87c5418a961fd2c (diff) |
Address some code-analysis issues.
Expression '...' is always true.
The 'b->init' variable is assigned values twice successively
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4753)
Diffstat (limited to 'crypto/bio')
-rw-r--r-- | crypto/bio/bss_acpt.c | 1 | ||||
-rw-r--r-- | crypto/bio/bss_mem.c | 28 |
2 files changed, 12 insertions, 17 deletions
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index f795b89145..e49c7ce5ea 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -450,7 +450,6 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) data->accepted_mode &= ~BIO_SOCK_NONBLOCK; break; case BIO_C_SET_FD: - b->init = 1; b->num = *((int *)ptr); data->accept_sock = b->num; data->state = ACPT_S_ACCEPT; diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c index 621472594a..a50d416f2d 100644 --- a/crypto/bio/bss_mem.c +++ b/crypto/bio/bss_mem.c @@ -147,23 +147,19 @@ static int mem_buf_free(BIO *a, int free_all) { if (a == NULL) return 0; - if (a->shutdown) { - if ((a->init) && (a->ptr != NULL)) { - BUF_MEM *b; - BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr; - - if (bb != NULL) { - b = bb->buf; - if (a->flags & BIO_FLAGS_MEM_RDONLY) - b->data = NULL; - BUF_MEM_free(b); - if (free_all) { - OPENSSL_free(bb->readp); - OPENSSL_free(bb); - } - } - a->ptr = NULL; + + if (a->shutdown && a->init && a->ptr != NULL) { + BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr; + BUF_MEM *b = bb->buf; + + if (a->flags & BIO_FLAGS_MEM_RDONLY) + b->data = NULL; + BUF_MEM_free(b); + if (free_all) { + OPENSSL_free(bb->readp); + OPENSSL_free(bb); } + a->ptr = NULL; } return 1; } |