From c4f7bae10b335409999cc2e6013ae238327906e1 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 11 Mar 2016 22:15:02 -0800 Subject: [PATCH] GUAC-236: Do not create output file until after everything has been validated. --- src/guacenc/encode.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/guacenc/encode.c b/src/guacenc/encode.c index 680bb31d..d7fe8eba 100644 --- a/src/guacenc/encode.c +++ b/src/guacenc/encode.c @@ -86,17 +86,18 @@ static int guacenc_read_instructions(guacenc_display* display, int guacenc_encode(const char* path, const char* out_path, const char* codec, int width, int height, int bitrate) { - /* Allocate display for encoding process */ - guacenc_display* display = guacenc_display_alloc(out_path, codec, - width, height, bitrate); - if (display == NULL) - return 1; - /* Open input file */ int fd = open(path, O_RDONLY); if (fd < 0) { guacenc_log(GUAC_LOG_ERROR, "%s: %s", path, strerror(errno)); - guacenc_display_free(display); + return 1; + } + + /* Allocate display for encoding process */ + guacenc_display* display = guacenc_display_alloc(out_path, codec, + width, height, bitrate); + if (display == NULL) { + close(fd); return 1; }