Mesa (staging/20.1): zink: Check fopen result.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun May 31 23:07:48 UTC 2020
Module: Mesa
Branch: staging/20.1
Commit: bd454f09654798bfcbb0568506a59eeb99411d0e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd454f09654798bfcbb0568506a59eeb99411d0e
Author: Vinson Lee <vlee at freedesktop.org>
Date: Wed May 27 16:19:25 2020 -0700
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 <vlee at freedesktop.org>
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5235>
(cherry picked from commit a2ee293422c09c9ecc8150ad70d29273e28c6a71)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/zink_compiler.c | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 8c4a5479bda..127c6e84ee4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -697,7 +697,7 @@
"description": "zink: Check fopen result.",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "8d46e35d16e3936968958bcab86d61967a673305"
},
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 5db5ba3fe0a..73ede848b97 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -277,9 +277,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 = {};
More information about the mesa-commit
mailing list