]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/ssl_old_test.c: Fix potential leak
authorPeiwei Hu <jlu.hpw@foxmail.com>
Tue, 12 Oct 2021 02:50:12 +0000 (10:50 +0800)
committerTomas Mraz <tomas@openssl.org>
Fri, 15 Oct 2021 06:54:37 +0000 (08:54 +0200)
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16806)

test/ssl_old_test.c

index 60a275a014a221e7e3245540f8b43424d9844b7f..3ccc8e06e4c045658fe951aa2714ba340c6388a6 100644 (file)
@@ -829,12 +829,14 @@ static SSL_SESSION *read_session(const char *filename)
 
 static int write_session(const char *filename, SSL_SESSION *sess)
 {
-    BIO *f = BIO_new_file(filename, "w");
+    BIO *f;
 
     if (sess == NULL) {
         BIO_printf(bio_err, "No session information\n");
         return 0;
     }
+
+    f = BIO_new_file(filename, "w");
     if (f == NULL) {
         BIO_printf(bio_err, "Can't open session file %s\n", filename);
         ERR_print_errors(bio_err);