Replace g_memdup with safer g_memdup2
authorTomasz Golinski <tomaszg@math.uwb.edu.pl>
Mon, 15 May 2023 21:57:13 +0000 (23:57 +0200)
committerColin Clark <colin.clark@cclark.uk>
Tue, 16 May 2023 12:23:20 +0000 (13:23 +0100)
g_memdup is declared as deprecated in current GLib, safer replacement g_memdup2 is available since GLib-2.68.

Code is protected by GLIB_CHECK_VERSION macro, so should build on older distros as well.

See https://docs.gtk.org/glib/func.memdup2.html

src/exiv2.cc

index 305061b..a2c16c4 100644 (file)
@@ -267,7 +267,11 @@ public:
                if (cp_data_)
                {
                        if (data_len) *data_len = cp_length_;
                if (cp_data_)
                {
                        if (data_len) *data_len = cp_length_;
+#if GLIB_CHECK_VERSION(2,68,0)
+                       return (unsigned char *) g_memdup2(cp_data_, cp_length_);
+#else
                        return (unsigned char *) g_memdup(cp_data_, cp_length_);
                        return (unsigned char *) g_memdup(cp_data_, cp_length_);
+#endif
                }
                return NULL;
        }
                }
                return NULL;
        }