From a0fda2cf2dac8bc0d309261b3aaf4027a188b08c Mon Sep 17 00:00:00 2001 From: FdaSilvaYY Date: Fri, 8 Dec 2017 10:49:41 -0500 Subject: Address some code-analysis issues. Expression '...' is always true. The 'b->init' variable is assigned values twice successively Reviewed-by: Kurt Roeckx Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/4753) --- crypto/bio/bss_mem.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'crypto/bio/bss_mem.c') 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; } -- cgit v1.2.3