From 857562bf9d7fe375e75a382c2b190316ee6677d1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 May 2017 17:46:01 +0200 Subject: [PATCH] Prevent immediate crash when compiling with SANITIZER=address --- gfx/video_shader_parse.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index e832a810d9..a068796354 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -487,19 +487,20 @@ bool video_shader_resolve_parameters(config_file_t *conf, for (i = 0; i < shader->passes; i++) { + char line[4096]; + RFILE *file = NULL; + const char *path = shader->pass[i].source.path; #ifdef HAVE_SLANG /* First try to use the more robust slang implementation to support #includes. */ /* FIXME: The check for slang can be removed if it's sufficiently tested for * GLSL/Cg as well, it should be the same implementation. */ - if ((string_is_equal_fast(path_get_extension(shader->pass[i].source.path), "slang", 5)) && + if (!string_is_empty(path) && (string_is_equal_fast(path_get_extension(path), "slang", 5)) && slang_preprocess_parse_parameters(shader->pass[i].source.path, shader)) continue; /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ #endif - - char line[4096]; - RFILE *file = filestream_open(shader->pass[i].source.path, RFILE_MODE_READ_TEXT, -1); + file = filestream_open(shader->pass[i].source.path, RFILE_MODE_READ_TEXT, -1); if (!file) continue;