GUACAMOLE-465: Merge remove superfluous access check prior to attempting file deletion.

This commit is contained in:
Virtually Nick 2020-06-24 20:10:34 -04:00 committed by GitHub
commit 3a87dd0c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,10 +37,11 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
@ -160,10 +161,11 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
fail_alloc_video: fail_alloc_video:
fail_output_file: fail_output_file:
avio_close(container_format_context->pb); avio_close(container_format_context->pb);
/* delete the file that was created if it was actually created */
if (access(path, F_OK) != -1) { /* Delete the file that was created if it was actually created */
remove(path); if (unlink(path) == -1 && errno != ENOENT)
} guacenc_log(GUAC_LOG_WARNING, "Failed output file \"%s\" could not "
"be automatically deleted: %s", path, strerror(errno));
fail_output_avio: fail_output_avio:
av_freep(&frame->data[0]); av_freep(&frame->data[0]);