diff options
author | yenatch <yenatch@gmail.com> | 2017-12-28 01:31:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-28 01:31:00 -0500 |
commit | e2b378f5e32ea1416fbc9ac5e96d23be244e4a6b (patch) | |
tree | 70fd1d4709150af457258763be04960931acd95b /tools/gfx.c | |
parent | da28d1a84b0499bead314e17ae2ff0d13eb03196 (diff) | |
parent | 9af2aee640b555f9f52503233bc06d299b99974d (diff) |
Merge pull request #442 from yenatch/fix-fread
fix fread warnings
Diffstat (limited to 'tools/gfx.c')
-rw-r--r-- | tools/gfx.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/gfx.c b/tools/gfx.c index 3e5624e95..8c4066ab3 100644 --- a/tools/gfx.c +++ b/tools/gfx.c @@ -230,8 +230,13 @@ int png_get_width(char *filename) { const int OFFSET_WIDTH = 16; uint8_t bytes[4]; fseek(f, OFFSET_WIDTH, SEEK_SET); - fread(bytes, 1, 4, f); + size_t size = 4; + size_t result = fread(bytes, 1, size, f); fclose(f); + if (result != size) { + fprintf(stderr, "Could not read file at offset 0x%x: \"%s\"\n", OFFSET_WIDTH, filename); + exit(1); + } int width = 0; for (int i = 0; i < 4; i++) { |