pan/clc: handle seek-error

lseek can return a negative value on error here. While it's not likely
to happen, let's add some error-checking here to prevent bad behavior if
we're unlucky.

CID: 1648299
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36724>
This commit is contained in:
Erik Faye-Lund 2025-08-11 15:43:03 +02:00 committed by Marge Bot
parent f886e08f36
commit 046710ce95

View file

@ -285,6 +285,13 @@ main(int argc, const char **argv)
}
off_t spirv_len = lseek(fd, 0, SEEK_END);
if (spirv_len < 0) {
fprintf(stderr, "Failed to lseek to the end of the file: errno=%d, %s\n",
errno, strerror(errno));
close(fd);
goto input_spirv_open_failed;
}
const void *spirv_map = mmap(NULL, spirv_len, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);