changeset 2271:60ed39a3a285

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 <pizza@shaftnet.org> Signed-off-by: Klaus Ethgen <Klaus@Ethgen.de>
author Solomon Peachy <pizza@shaftnet.org>
date Thu, 03 Mar 2016 19:47:26 -0500
parents 132757bcc430
children 56ffcc384eb8 bc378aaab4f9
files src/exiv2.cc
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/exiv2.cc	Fri Mar 04 09:14:17 2016 +0100
+++ b/src/exiv2.cc	Thu Mar 03 19:47:26 2016 -0500
@@ -160,6 +160,7 @@
 	unsigned char *cp_data_;
 	guint cp_length_;
 	gboolean valid_;
+	gchar *pathl_;
 
 	Exiv2::ExifData emptyExifData_;
 	Exiv2::IptcData emptyIptcData_;
@@ -182,10 +183,10 @@
 		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 @@
 			{
 			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 @@
 
 	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;