# HG changeset patch # User nadvornik # Date 1228656484 0 # Node ID 4fe35e07308d9e9e80c0492839734dc9b904a744 # Parent 98f8d5746b92a19dde6b467f5539114d22e33e6c handle the case when io.open() fails diff -r 98f8d5746b92 -r 4fe35e07308d src/exiv2.cc --- a/src/exiv2.cc Sat Dec 06 21:24:38 2008 +0000 +++ b/src/exiv2.cc Sun Dec 07 13:28:04 2008 +0000 @@ -145,9 +145,12 @@ Exiv2::BasicIo &io = image_->io(); gint open = io.isopen(); if (!open) io.open(); - unsigned char *mapped = (unsigned char*)io.mmap(); - if (mapped) exif_jpeg_parse_color(this, mapped, io.size()); - io.munmap(); + if (io.isopen()) + { + unsigned char *mapped = (unsigned char*)io.mmap(); + if (mapped) exif_jpeg_parse_color(this, mapped, io.size()); + io.munmap(); + } if (!open) io.close(); } #endif