fix crash on some strange data from Pentax device, thanks Harald Lenz
authorGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 31 Dec 2010 22:00:28 +0000 (23:00 +0100)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 31 Dec 2010 22:00:28 +0000 (23:00 +0100)
ext/rbbooh.cc

index 86ff865..da8cc15 100644 (file)
@@ -98,7 +98,7 @@ static VALUE exif_orientation(VALUE module, VALUE filename) {
                         return Qnil;
                 }
                 Exiv2::ExifData::const_iterator i = exifData.findKey(Exiv2::ExifKey("Exif.Image.Orientation"));
-                if (i != exifData.end()) {
+                if (i != exifData.end() && i->count() > 0) {
                         return INT2NUM(i->value().toLong());
                 }
                 return Qnil;
@@ -132,7 +132,7 @@ static VALUE exif_datetimeoriginal(VALUE module, VALUE filename) {
                         return Qnil;
                 }
                 Exiv2::ExifData::const_iterator i = exifData.findKey(Exiv2::ExifKey("Exif.Photo.DateTimeOriginal"));
-                if (i != exifData.end()) {
+                if (i != exifData.end() && i->count() > 0) {
                         return rb_str_new2(i->value().toString().c_str());
                 }
                 return Qnil;