summaryrefslogtreecommitdiff
path: root/glib/src
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2019-07-08 16:27:35 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2019-07-08 16:27:35 +0200
commitababc413ffbbcc22ccc0af6675285183d5ef9e69 (patch)
tree125a04e2c5dc31d2ec1e81bc3bb82b05929af17f /glib/src
parent0815ad6d741a768e69107d78dc4af8c7588e0f6a (diff)
downloadglibmm-ababc413ffbbcc22ccc0af6675285183d5ef9e69.tar.gz
Glib::Variant<std::tuple<>>::create(): Fix memory leak
Fixes #48
Diffstat (limited to 'glib/src')
-rw-r--r--glib/src/variant.hg5
1 files changed, 3 insertions, 2 deletions
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index d570dcb8..ff791df4 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>
@@ -1512,13 +1513,13 @@ Variant<std::tuple<Types...>>::create(const std::tuple<Types...>& data)
detail::expand_tuple(variants, data, std::index_sequence_for<Types...>{});
using var_ptr = GVariant*;
- var_ptr* const var_array = new var_ptr[sizeof... (Types)];
+ auto var_array = std::make_unique<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;
}