[gexiv2/wip/gio-fix: 2/3] gioio: Fix crash on CRW files



commit 5c6184318b24c00d6955bea5c38eb48a83ba0c57
Author: Jens Georg <mail jensge org>
Date:   Sun Oct 6 18:12:23 2019 +0200

    gioio: Fix crash on CRW files

 gexiv2/gexiv2-metadata.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/gexiv2/gexiv2-metadata.cpp b/gexiv2/gexiv2-metadata.cpp
index ac6e269..9ea9a19 100644
--- a/gexiv2/gexiv2-metadata.cpp
+++ b/gexiv2/gexiv2-metadata.cpp
@@ -47,6 +47,8 @@ public:
     using size_type = long;
 #endif
 
+    size_type _size;
+
     ~GioIo() { g_clear_object (&_is); g_clear_error (&_error); _seekable = NULL;}
 #if defined(_MSC_VER)
     typedef int64_t seek_offset_t;
@@ -61,6 +63,14 @@ public:
 #endif
 
     int open() {
+        if (_seekable == nullptr)
+            return 0;
+
+        auto position = tell();
+        seek (0, Exiv2::BasicIo::end);
+        _size = tell();
+        seek (position, Exiv2::BasicIo::beg);
+
         return 0;
     }
 
@@ -187,7 +197,7 @@ public:
     }
 
     size_t size() const {
-        return -1;
+        return static_cast<size_t>(_size);
     }
 
     bool isopen() const {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]