From 2799676218249c5b9f1dc0a6367e459a1ad5642e Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Sun, 2 Feb 2020 17:15:09 +0000 Subject: [PATCH] util/disk_cache: check for write() failure in the zstd path CoverityID: 1458074 Fixes: a8d941091f72923561a6 ("util: Use ZSTD for shader cache if possible") Signed-off-by: Eric Engestrom Reviewed-by: Dylan Baker Tested-by: Marge Bot Part-of: --- src/util/disk_cache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index e5b21b9a79f..d1f14736725 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -758,7 +758,11 @@ deflate_and_write_to_disk(const void *in_data, size_t in_data_size, int dest, free(out); return 0; } - write_all(dest, out, ret); + ssize_t written = write_all(dest, out, ret); + if (written == -1) { + free(out); + return 0; + } free(out); return ret; #else -- 2.30.2