Hi Friends, David Kalnischkies did a good find in new libstdc++5 that recently occurred in debian. I forwarded the full message from bug report for you to know.
For David, thanks for the good finding. I will consider the patch or just do it more simple as having a local scope temporary variable or even using strncpy. Geeqie is usually plain C and only the exif part is done in c++ for the reason, the exiv2 bindings are c++ only. Regards Klaus -- Klaus Ethgen http://www.ethgen.ch/ pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen <kl...@ethgen.de> Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C
--- Begin Message ---Hi, On Mon, Sep 28, 2015 at 11:56:12AM +0200, Michal Hocko wrote: > The older version displays the same image as having 3872x2592px. I would > bet the newer version picks up a thumbnail stored in the NEF file or > something like that. The problem is rooted in the libstdc++5 transition as with it they transitioned to have a c++11-standard compatible std::string implementation. Previously it was a copy-on-write implementation, now it is one with small-string optimisation. So code like this: | const char* path = exif->image()->io().path().c_str(); results in path being a dangling pointer now as the std::string returned by .path() on which .c_str() is called (which returns the char*) leaves scope instantly and hence the internal char[] the pointer is pointing to is freed… It worked before as the std::string returned by .path() was a copy of another std::string, so the char pointer is still pointing to a valid location. At least as long as the copy source remains. Change the "unrelated" code a bit so its not a copy anymore and suddently this code explodes… (No worries, this isn't by far the only application with this problem – it is just more likely that it results in a crash instead of not detecting a file as RAW in most other applications ;) ) Anyway, upstream should probably look for more instances as the attached patch is likely incomplete. It just got the NEF previews working again for me. Best regards David Kalnischkiesdiff --git a/src/exiv2.cc b/src/exiv2.cc index 455c8d3..98029cd 100644 --- a/src/exiv2.cc +++ b/src/exiv2.cc @@ -16,6 +16,7 @@ #include <exiv2/image.hpp> #include <exiv2/exif.hpp> #include <iostream> +#include <string> // EXIV2_TEST_VERSION is defined in Exiv2 0.15 and newer. #ifndef EXIV2_TEST_VERSION @@ -1130,9 +1131,9 @@ 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(); + std::string const path = exif->image()->io().path(); /* 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(path.c_str(), FORMAT_CLASS_RAWIMAGE); if (!is_raw && requested_width == 0) return NULL; @@ -1232,10 +1233,10 @@ extern "C" guchar *exif_get_preview(ExifData *exif, guint *data_len, gint reques if (!exif) return NULL; if (!exif->image()) return NULL; - const char* path = exif->image()->io().path().c_str(); + std::string const path = exif->image()->io().path(); /* given image pathname, first do simple (and fast) file extension test */ - if (!filter_file_class(path, FORMAT_CLASS_RAWIMAGE)) return NULL; + if (!filter_file_class(path.c_str(), FORMAT_CLASS_RAWIMAGE)) return NULL; try { struct stat st; @@ -1246,9 +1247,9 @@ extern "C" guchar *exif_get_preview(ExifData *exif, guint *data_len, gint reques RawFile rf(exif->image()->io()); offset = rf.preview_offset(); - DEBUG_1("%s: offset %lu", path, offset); + DEBUG_1("%s: offset %lu", path.c_str(), offset); - fd = open(path, O_RDONLY); + fd = open(path.c_str(), O_RDONLY); if (fd == -1) { return NULL;
signature.asc
Description: PGP signature
--- End Message ---
signature.asc
Description: PGP signature
------------------------------------------------------------------------------
_______________________________________________ Geeqie-devel mailing list Geeqie-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geeqie-devel