From: Vinson Lee Date: Wed, 27 May 2020 23:19:25 +0000 (-0700) Subject: zink: Check fopen result. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a2ee293422c09c9ecc8150ad70d29273e28c6a71;p=mesa.git zink: Check fopen result. Fix warning reported by Coverity. Dereference null return value (NULL_RETURNS) dereference: Dereferencing a pointer that might be NULL fp when calling fwrite. Fixes: 8d46e35d16e3 ("zink: introduce opengl over vulkan") Signed-off-by: Vinson Lee Reviewed-by: Erik Faye-Lund Part-of: --- diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 1d9d21df3fe..98ef706fb8f 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -195,9 +195,11 @@ zink_compile_nir(struct zink_screen *screen, struct nir_shader *nir) static int i; snprintf(buf, sizeof(buf), "dump%02d.spv", i++); FILE *fp = fopen(buf, "wb"); - fwrite(spirv->words, sizeof(uint32_t), spirv->num_words, fp); - fclose(fp); - fprintf(stderr, "wrote '%s'...\n", buf); + if (fp) { + fwrite(spirv->words, sizeof(uint32_t), spirv->num_words, fp); + fclose(fp); + fprintf(stderr, "wrote '%s'...\n", buf); + } } VkShaderModuleCreateInfo smci = {};