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: 8d46e35d16 ("zink: introduce opengl over vulkan")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5235>
This commit is contained in:
Vinson Lee 2020-05-27 16:19:25 -07:00 committed by Michel Dänzer
parent 7503863fe2
commit a2ee293422
1 changed files with 5 additions and 3 deletions

View File

@ -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 = {};