gomfunkel/node-exif — pull request #14 by lhagan (2013-06-12 04:18:03+00:00)
Title: Handle invalid IFD

I ran `node-exif` over about 6000 photos, and it got hung up on just one. In this case, it looks like the IFD was invalid, so whereas there would normally be a few IFD entires to loop over, `node-exif` detected over 10000. Not exactly an infinite loop, but it at least approximates one. This is definitely a problem with the image; `exiftool` fails gracefully and reports: "Bad ExifIFD directory" when reading the same file.

I was able to quickly fix this by adding a sanity check: if the number of entries exceeds 1000, something's got to be wrong so I had it bail out. There's probably a better way to solve this problem, but I figured submitting a pull request would at least be a good way to bring attention to this edge case.