From 67e472b4b8c8406bf2f9ebf3418e43ba12cd3dbb Mon Sep 17 00:00:00 2001 From: Ingo Date: Sun, 22 Jun 2014 17:21:47 +0200 Subject: [PATCH] Win64 build crashes opening folder containing MRW files, Issue 2425 --- rtengine/rtthumbnail.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 50202dfb2..3f16e40b4 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -153,7 +153,16 @@ Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataL const char* data((const char*)fdata(ri->get_thumbOffset(),ri->get_file())); if ( (unsigned char)data[1] == 0xd8 ) { +#if defined( __WIN32__ ) && defined( __x86_64__ ) + // This is a hack for Issue 2425, because loadJPEGFromMemory crashes on Win64 when jpg marker is incorrect + // (should be 0xff 0xd8, but is 0x02 0xd8 for mrw files) + std::string suffix = fname.length() > 4 ? fname.substr(fname.length()-3) : ""; + for (int i = 0; i < suffix.length(); i++) suffix[i] = std::tolower(suffix[i]); + if(suffix != "mrw" || (unsigned char)data[0] == 0xff) + err = img->loadJPEGFromMemory(data,ri->get_thumbLength()); +#else err = img->loadJPEGFromMemory(data,ri->get_thumbLength()); +#endif } else {