GUAC-236: Do not create output file until after everything has been validated.

This commit is contained in:
Michael Jumper 2016-03-11 22:15:02 -08:00
parent 3d67598ec9
commit c4f7bae10b

View File

@ -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 guacenc_encode(const char* path, const char* out_path, const char* codec,
int width, int height, int bitrate) { 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 */ /* Open input file */
int fd = open(path, O_RDONLY); int fd = open(path, O_RDONLY);
if (fd < 0) { if (fd < 0) {
guacenc_log(GUAC_LOG_ERROR, "%s: %s", path, strerror(errno)); 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; return 1;
} }