From: Emil Velikov Date: Wed, 12 Mar 2014 16:58:26 +0000 (+0000) Subject: nouveau: honor fread return value in the nouveau_compiler X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ad4a44ebfc9f72d34bf3523e455822896a788507;p=mesa.git nouveau: honor fread return value in the nouveau_compiler There is little point of continuing if fread returns zero, as it indicates that either the file is empty or cannot be read from. Bail out if fread returns zero after closing the file. Cc: Ilia Mirkin Signed-off-by: Emil Velikov Reviewed-by: Ilia Mirkin --- diff --git a/src/gallium/drivers/nouveau/nouveau_compiler.c b/src/gallium/drivers/nouveau/nouveau_compiler.c index 5f1e35a0d24..ac22035ca82 100644 --- a/src/gallium/drivers/nouveau/nouveau_compiler.c +++ b/src/gallium/drivers/nouveau/nouveau_compiler.c @@ -173,9 +173,9 @@ main(int argc, char *argv[]) return 1; } - fread(text, 1, sizeof(text), f); - if (ferror(f)) { + if (!fread(text, 1, sizeof(text), f) || ferror(f)) { _debug_printf("Error reading file '%s'\n", filename); + fclose(f); return 1; } fclose(f);