From fa63b2f7a6a2cc949d9c8a072a88eacb57fb353e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Thu, 23 May 2019 15:34:06 +0200 Subject: [PATCH] Fix EXV_UNICODE_PATH `std::wstring` conversion --- rtengine/imagedata.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index 1890739b8..6897490ac 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -41,8 +41,13 @@ extern const Settings *settings; Exiv2::Image::AutoPtr open_exiv2(const Glib::ustring& fname) { #ifdef EXV_UNICODE_PATH - const auto* const ws = g_utf8_to_utf16(fname.c_str(), -1, NULL, NULL, NULL); - const std::wstring wfname(ws); + glong ws_size = 0; + gunichar2* const ws = g_utf8_to_utf16(fname.c_str(), -1, nullptr, &ws_size, nullptr); + std::wstring wfname; + wfname.reserve(ws_size); + for (glong i = 0; i < ws_size; ++i) { + wfname.push_back(ws[i]); + } g_free(ws); auto image = Exiv2::ImageFactory::open(wfname); #else