From 88c0024a5284b16b82c8ce931ca7e852194a5a37 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 4 Sep 2020 03:49:41 +0200 Subject: [PATCH] Cleanup video_shader_read_reference_path --- gfx/video_shader_parse.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 86b35f8e4e..e8c3b80311 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -695,14 +695,14 @@ char *video_shader_read_reference_path(const char *path) char *line = NULL; if (string_is_empty(path)) - goto end; + return NULL; if (!path_is_valid(path)) - goto end; + return NULL; file = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) - goto end; + return NULL; line = filestream_getline(file); filestream_close(file); @@ -713,7 +713,10 @@ char *video_shader_read_reference_path(const char *path) /* have at least 1 whitespace */ if (!isspace((unsigned char)*ref_path)) - goto end; + { + free(line); + return NULL; + } ref_path++; while (isspace((unsigned char)*ref_path)) @@ -748,12 +751,18 @@ char *video_shader_read_reference_path(const char *path) } if (string_is_empty(ref_path)) - goto end; + { + free(line); + return NULL; + } reference = (char *)malloc(PATH_MAX_LENGTH); if (!reference) - goto end; + { + free(line); + return NULL; + } /* rebase relative reference path */ if (!path_is_absolute(ref_path)) @@ -763,7 +772,6 @@ char *video_shader_read_reference_path(const char *path) strlcpy(reference, ref_path, PATH_MAX_LENGTH); } -end: if (line) free(line);