util/disk_cache: check for write() failure in the zstd path
authorEric Engestrom <eric@engestrom.ch>
Sun, 2 Feb 2020 17:15:09 +0000 (17:15 +0000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 5 Feb 2020 01:09:04 +0000 (01:09 +0000)
CoverityID: 1458074
Fixes: a8d941091f72923561a6 ("util: Use ZSTD for shader cache if possible")
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3672>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3672>

src/util/disk_cache.c

index e5b21b9a79f5620c4f040561908a2a299a7c1df6..d1f147367252451f5ef387b1d5f6599f40c480ad 100644 (file)
@@ -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