@@ -2743,7 +2743,7 @@ static int verify_signed_file(FILE_FORMAT_CTX *ctx, GLOBAL_OPTIONS *options)
27432743 return 1 ; /* FAILED */
27442744 }
27452745 p7 = cat_ctx -> format -> pkcs7_extract (cat_ctx );
2746- cat_ctx -> format -> ctx_cleanup (cat_ctx , NULL , NULL );
2746+ cat_ctx -> format -> ctx_cleanup (cat_ctx );
27472747 OPENSSL_free (cat_options );
27482748 } else {
27492749 if (!ctx -> format -> pkcs7_extract ) {
@@ -2970,11 +2970,11 @@ static int check_attached_data(GLOBAL_OPTIONS *options)
29702970 }
29712971 if (verify_signed_file (ctx , tmp_options )) {
29722972 printf ("Signature mismatch\n" );
2973- ctx -> format -> ctx_cleanup (ctx , NULL , NULL );
2973+ ctx -> format -> ctx_cleanup (ctx );
29742974 OPENSSL_free (tmp_options );
29752975 return 1 ; /* Failed */
29762976 }
2977- ctx -> format -> ctx_cleanup (ctx , NULL , NULL );
2977+ ctx -> format -> ctx_cleanup (ctx );
29782978 OPENSSL_free (tmp_options );
29792979 return 0 ; /* OK */
29802980}
@@ -4440,6 +4440,7 @@ int main(int argc, char **argv)
44404440 }
44414441 BIO_free_all (hash );
44424442 BIO_free_all (outdata );
4443+ outdata = NULL ;
44434444 ret = 1 ; /* FAILED */
44444445 DO_EXIT_0 ("Initialization error or unsupported input file type.\n" );
44454446 }
@@ -4580,7 +4581,8 @@ int main(int argc, char **argv)
45804581
45814582skip_signing :
45824583 if (ctx -> format -> bio_free ) {
4583- outdata = ctx -> format -> bio_free (hash , outdata );
4584+ ctx -> format -> bio_free (hash , outdata );
4585+ outdata = NULL ;
45844586 }
45854587 if (!ret && options .cmd == CMD_ATTACH ) {
45864588 ret = check_attached_data (& options );
@@ -4594,12 +4596,17 @@ int main(int argc, char **argv)
45944596 }
45954597
45964598err_cleanup :
4597- if (outdata && options .outfile ) {
4598- /* unlink outfile */
4599- remove_file (options .outfile );
4599+ if (outdata ) {
4600+ if (options .outfile ) {
4601+ /* unlink outfile */
4602+ remove_file (options .outfile );
4603+ }
4604+ if (hash )
4605+ BIO_free (hash );
4606+ BIO_free (outdata );
46004607 }
46014608 if (ctx && ctx -> format -> ctx_cleanup ) {
4602- ctx -> format -> ctx_cleanup (ctx , hash , outdata );
4609+ ctx -> format -> ctx_cleanup (ctx );
46034610 }
46044611#if OPENSSL_VERSION_NUMBER >=0x30000000L
46054612 providers_cleanup ();
0 commit comments