--- profilea.c 2016-10-11 17:51:01.181070243 +0900 +++ profile.c 2016-10-11 17:53:35.757015859 +0900 @@ -2060,7 +2060,7 @@ (void) AddValueToSplayTree(exif_resources,q,q); tag_value=(ssize_t) ReadProfileShort(endian,q); format=(ssize_t) ReadProfileShort(endian,q+2); - if ((format-1) >= EXIF_NUM_FORMATS) + if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS)) break; components=(ssize_t) ReadProfileLong(endian,q+4); if (components < 0)