From 4cabdb80c5e392d8b78e921608d5367e58c34a13 Mon Sep 17 00:00:00 2001 From: Eukara Date: Sat, 10 Nov 2018 08:26:51 +0000 Subject: [PATCH] Fixed r_showshaders crashing on a surface without shadername. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5335 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/gl/gl_shader.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 115308964..96f62be01 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -7299,22 +7299,24 @@ char *Shader_GetShaderBody(shader_t *s, char *fname, size_t fnamesize) } } } - - if (!strchr(parsename, ':')) - { - //if the named shader is a .shader file then just directly load it. - const char *token = COM_GetFileExtension(parsename, NULL); - if (!strcmp(token, ".shader") || !*token) + + if ( parsename ) { + if (!strchr(parsename, ':')) { - char shaderfile[MAX_QPATH]; - if (!*token) + //if the named shader is a .shader file then just directly load it. + const char *token = COM_GetFileExtension(parsename, NULL); + if (!strcmp(token, ".shader") || !*token) { - Q_snprintfz(shaderfile, sizeof(shaderfile), "%s.shader", parsename); - if (COM_FCheckExists(shaderfile)) - Q_snprintfz(fname, fnamesize, "%s:%i", shaderfile, 1); + char shaderfile[MAX_QPATH]; + if (!*token) + { + Q_snprintfz(shaderfile, sizeof(shaderfile), "%s.shader", parsename); + if (COM_FCheckExists(shaderfile)) + Q_snprintfz(fname, fnamesize, "%s:%i", shaderfile, 1); + } + else if (COM_FCheckExists(parsename)) + Q_snprintfz(fname, fnamesize, "%s:%i", parsename, 1); } - else if (COM_FCheckExists(parsename)) - Q_snprintfz(fname, fnamesize, "%s:%i", parsename, 1); } } }