summaryrefslogtreecommitdiffstats
path: root/crypto/err/err_prn.c
diff options
context:
space:
mode:
authorFdaSilvaYY <fdasilvayy@gmail.com>2016-03-19 00:40:11 +0100
committerMatt Caswell <matt@openssl.org>2016-03-29 18:40:54 +0200
commit1a50b8139a6221d65bc526ab415c77b0561ff708 (patch)
tree90a4421c0a3a119dc3352b931030f4dccc085420 /crypto/err/err_prn.c
parentpoly1305/asm/poly1305-x86.pl: don't loose 59-th bit. (diff)
downloadopenssl-1a50b8139a6221d65bc526ab415c77b0561ff708.tar.xz
openssl-1a50b8139a6221d65bc526ab415c77b0561ff708.zip
Fix a big leak when using stack-allocated BIO items.
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto/err/err_prn.c')
-rw-r--r--crypto/err/err_prn.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c
index ac6b81f80b..0f7d40c398 100644
--- a/crypto/err/err_prn.c
+++ b/crypto/err/err_prn.c
@@ -92,23 +92,6 @@ void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
}
}
-#ifndef OPENSSL_NO_STDIO
-static int print_fp(const char *str, size_t len, void *fp)
-{
- BIO bio;
-
- BIO_set(&bio, BIO_s_file());
- BIO_set_fp(&bio, fp, BIO_NOCLOSE);
-
- return BIO_printf(&bio, "%s", str);
-}
-
-void ERR_print_errors_fp(FILE *fp)
-{
- ERR_print_errors_cb(print_fp, fp);
-}
-#endif
-
static int print_bio(const char *str, size_t len, void *bp)
{
return BIO_write((BIO *)bp, str, len);
@@ -118,3 +101,15 @@ void ERR_print_errors(BIO *bp)
{
ERR_print_errors_cb(print_bio, bp);
}
+
+#ifndef OPENSSL_NO_STDIO
+void ERR_print_errors_fp(FILE *fp)
+{
+ BIO *bio = BIO_new_fp(fp, BIO_NOCLOSE);
+ if (bio == NULL)
+ return;
+
+ ERR_print_errors_cb(print_bio, bio);
+ BIO_free(bio);
+}
+#endif