add additional checks + cleanup
[openssl.git] / crypto / bio / bss_file.c
index 9e161b17f508076ceeea2f34e74a6098e76f7796..b7504baf20d4f9ce1f3655bd9c31e3f8c4866c82 100644 (file)
@@ -128,7 +128,10 @@ BIO *BIO_new_file(const char *filename, const char *mode)
                return(NULL);
                }
        if ((ret=BIO_new(BIO_s_file())) == NULL)
+               {
+               fclose(file);
                return(NULL);
+               }
 
        BIO_clear_flags(ret,BIO_FLAGS_UPLINK); /* we did fopen -> we disengage UPLINK */
        BIO_set_fp(ret,file,BIO_CLOSE);