Fix memory leaks in conf_def.c
authorluxinyou <luxinyou@uniontech.com>
Mon, 7 Sep 2020 08:06:45 +0000 (18:06 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Mon, 7 Sep 2020 08:06:45 +0000 (18:06 +1000)
Fixes #12471
CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12533)

crypto/conf/conf_def.c

index 1d34519d1aa5f29615cab735191551477a01093c..5475429abdc7c71170f8a9daaac51e13a76c1c01 100644 (file)
@@ -442,11 +442,13 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
                     if (biosk == NULL) {
                         if ((biosk = sk_BIO_new_null()) == NULL) {
                             CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+                            BIO_free(next);
                             goto err;
                         }
                     }
                     if (!sk_BIO_push(biosk, in)) {
                         CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+                        BIO_free(next);
                         goto err;
                     }
                     /* continue with reading from the included BIO */