asn1parse: create the out bio during init, free it during cleanup
authorKurt Roeckx <kurt@roeckx.be>
Sat, 19 Nov 2016 16:24:39 +0000 (17:24 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Fri, 2 Dec 2016 23:14:14 +0000 (00:14 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #2023

fuzz/asn1parse.c

index edb4d023030273f199208a4645a4c832b38e0a11..3e11d350c1b68d5f1600cc7a100b742a36c779df 100644 (file)
 #include <openssl/x509v3.h>
 #include "fuzzer.h"
 
 #include <openssl/x509v3.h>
 #include "fuzzer.h"
 
+static BIO *bio_out;
+
 int FuzzerInitialize(int *argc, char ***argv)
 {
 int FuzzerInitialize(int *argc, char ***argv)
 {
+    bio_out = BIO_new_file("/dev/null", "w");
     return 1;
 }
 
 int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 {
     return 1;
 }
 
 int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 {
-    static BIO *bio_out;
-
-    if (bio_out == NULL)
-        bio_out = BIO_new_file("/dev/null", "w");
-
     (void)ASN1_parse_dump(bio_out, buf, len, 0, 0);
     return 0;
 }
 
 void FuzzerCleanup(void)
 {
     (void)ASN1_parse_dump(bio_out, buf, len, 0, 0);
     return 0;
 }
 
 void FuzzerCleanup(void)
 {
+    BIO_free(bio_out);
 }
 }