From b023b752cd6626b338ea72357bf9e61a40c816e6 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 23 Oct 2016 23:11:52 -0400 Subject: mdso_create_output(): do not leak fdout upon fopen failure. --- src/output/mdso_create_output.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/output') diff --git a/src/output/mdso_create_output.c b/src/output/mdso_create_output.c index 3eb95bc..5bbc50d 100644 --- a/src/output/mdso_create_output.c +++ b/src/output/mdso_create_output.c @@ -21,6 +21,7 @@ FILE * mdso_create_output( struct mdso_driver_ctx_impl * ictx; uintptr_t addr; int fdout; + FILE * fout; if (!dctx->cctx->dstdir) return stdout; @@ -33,5 +34,10 @@ FILE * mdso_create_output( S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) return 0; - return fdopen(fdout,"w"); + if (!(fout = fdopen(fdout,"w"))) { + close(fdout); + return 0; + } + + return fout; } -- cgit v1.2.3