mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 08:50:13 +01:00
intel/tools: handle ftell errors
Found by Coverity, as "argument cannot be negative", referring to fread's 2nd argument. Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6667>
This commit is contained in:
parent
46a82aa3a6
commit
5b6fd2a314
1 changed files with 7 additions and 3 deletions
|
|
@ -38,10 +38,10 @@ enum opt_input_type {
|
|||
static enum opt_input_type input_type = OPT_INPUT_BINARY;
|
||||
|
||||
/* Return size of file in bytes pointed by fp */
|
||||
static size_t
|
||||
static long
|
||||
i965_disasm_get_file_size(FILE *fp)
|
||||
{
|
||||
size_t size;
|
||||
long size;
|
||||
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
size = ftell(fp);
|
||||
|
|
@ -93,7 +93,11 @@ i965_disasm_read_binary(FILE *fp, size_t *end)
|
|||
size_t size;
|
||||
void *assembly;
|
||||
|
||||
*end = i965_disasm_get_file_size(fp);
|
||||
long sz = i965_disasm_get_file_size(fp);
|
||||
if (sz < 0)
|
||||
return NULL;
|
||||
|
||||
*end = (size_t)sz;
|
||||
if (!*end)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue