[gjs: 2/5] boxed: Also unset the GValue if allocated directly




commit c11f2581c44249421b47aa1487b519de2ff43227
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Oct 9 22:28:01 2020 +0200

    boxed: Also unset the GValue if allocated directly
    
    In case we've an allocated-directly GValue, freeing its pointer is not
    enough, as it may contain a string or a more complex type that actual
    need further actions.
    
    So, in such case also unset the GValue.

 gi/boxed.cpp | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index da07d534..ed879406 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -412,6 +412,8 @@ bool BoxedInstance::constructor_impl(JSContext* context, JS::HandleObject obj,
 BoxedInstance::~BoxedInstance() {
     if (m_owning_ptr) {
         if (m_allocated_directly) {
+            if (gtype() == G_TYPE_VALUE)
+                g_value_unset(static_cast<GValue*>(m_ptr));
             g_free(m_ptr);
         } else {
             if (g_type_is_a(gtype(), G_TYPE_BOXED))


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