[glibmm/glibmm-2-60] Glib::Variant<std::tuple<>>::create(): Fix memory leak



commit 0d5eb6516cbec8f8eaacf907930a04e058700878
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Jul 8 16:23:53 2019 +0200

    Glib::Variant<std::tuple<>>::create(): Fix memory leak
    
    Fixes #48

 glib/src/variant.hg | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 40732fe1..662448f3 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -26,6 +26,7 @@ _DEFS(glibmm,glib)
 #include <utility>
 #include <vector>
 #include <map>
+#include <memory>
 #include <tuple>
 #include <stdexcept>
 #include <typeinfo>
@@ -1593,13 +1594,13 @@ Variant<std::tuple<Types...>>::create(const std::tuple<Types...>& data)
   detail::expand_tuple(variants, data, detail::index_sequence_for<Types...>{});
 
   using var_ptr = GVariant*;
-  var_ptr* const var_array = new var_ptr[sizeof... (Types)];
+  std::unique_ptr<var_ptr[]> var_array(new var_ptr[sizeof... (Types)]);
 
   for (std::vector<VariantBase>::size_type i = 0; i < variants.size(); i++)
     var_array[i] = const_cast<GVariant*>(variants[i].gobj());
 
   Variant<std::tuple<Types...>> result = Variant<std::tuple<Types...>>(
-          g_variant_new_tuple(var_array, variants.size()));
+          g_variant_new_tuple(var_array.get(), variants.size()));
 
   return result;
 }


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