From 96db62d2afb70a4cba99a424122667d61ac6028b Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 3 Mar 2016 19:47:26 -0500 Subject: [PATCH] exiv2: Fix use-after-free of the image filename/path. This caused garbage to be returned when we attempted to use the path to determine if the file is a RAW image. Now, RAWs are detected properly and the proper full-res previews are used. Signed-off-by: Solomon Peachy Signed-off-by: Klaus Ethgen --- src/exiv2.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/exiv2.cc b/src/exiv2.cc index 97f08940..722afcf6 100644 --- a/src/exiv2.cc +++ b/src/exiv2.cc @@ -160,6 +160,7 @@ protected: unsigned char *cp_data_; guint cp_length_; gboolean valid_; + gchar *pathl_; Exiv2::ExifData emptyExifData_; Exiv2::IptcData emptyIptcData_; @@ -182,10 +183,10 @@ public: cp_length_ = 0; valid_ = TRUE; - gchar *pathl = path_from_utf8(path); + pathl_ = path_from_utf8(path); try { - image_ = Exiv2::ImageFactory::open(pathl); + image_ = Exiv2::ImageFactory::open(pathl_); // g_assert (image.get() != 0); image_->readMetadata(); @@ -219,12 +220,12 @@ public: { valid_ = FALSE; } - g_free(pathl); } virtual ~_ExifDataOriginal() { if (cp_data_) g_free(cp_data_); + if (pathl_) g_free(pathl_); } virtual Exiv2::Image *image() @@ -1130,9 +1131,8 @@ guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, if (!exif->image()) return NULL; - const char* path = exif->image()->io().path().c_str(); /* given image pathname, first do simple (and fast) file extension test */ - gboolean is_raw = filter_file_class(path, FORMAT_CLASS_RAWIMAGE); + gboolean is_raw = filter_file_class(exif->image()->io().path().c_str(), FORMAT_CLASS_RAWIMAGE); if (!is_raw && requested_width == 0) return NULL; -- 2.20.1