commit bf021b6653c962c98d193f8b494e33660aff46cd
parent ec398bcac7faba802d51f80715c6bc2c545727d4
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Sun, 18 Apr 2021 15:01:33 -0700
Rework ff_open internals
Since ntohl(3) returns an unsigned integer the image sizes
merely need their truth checked. Also the strange spacing was
modified.
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lel.c b/lel.c
@@ -81,17 +81,16 @@ ff_open(struct img *img, FILE *fp)
if (img->state & LOADED)
return 0;
- errno = EFTYPE;
+ errno = EFTYPE;
if (fread(hdr, sizeof(*hdr), 4, fp) != 4)
return -1;
-
if (memcmp(hdr, "farbfeld", 8))
return -1;
img->width = ntohl(hdr[2]);
img->height = ntohl(hdr[3]);
- if (img->width <= 0 || img->height <= 0)
+ if (!img->width || !img->height)
return -1;
if (!(img->buf = malloc(img->width * img->height * 4)))