]> 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:56:58 +0000 (08:56 +0200)
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16806)

(cherry picked from commit 34563be5368fb8e6ade7d06d8376522ba83cd6ac)

test/ssltest_old.c

index cc98e4f8665e8acad8306437d267afd268cf73a1..b6e21e4e18d9be653256fba3fe3d6a4c81c4e4f4 100644 (file)
@@ -841,12 +841,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);