[gjs: 4/5] object: Ensure weak ref callback is removed on finalize



commit 7e50b0fece7cd69780154c834c89a3eef182e2eb
Author: Philip Chimento <philip chimento gmail com>
Date:   Fri Apr 6 22:29:07 2018 -0700

    object: Ensure weak ref callback is removed on finalize
    
    A use-after-free bug was caused by an object's weak ref callback being
    called after the ObjectInstance* was freed.
    
    Closes #129.

 gi/object.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 08c6efb0..b20d8b90 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1523,7 +1523,9 @@ object_instance_finalize(JSFreeOp  *fop,
                     priv->info ? g_base_info_get_namespace((GIBaseInfo*) priv->info) : "",
                     priv->info ? g_base_info_get_name((GIBaseInfo*) priv->info) : g_type_name(priv->gtype));
         }
-        
+
+        if (!priv->g_object_finalized)
+            g_object_weak_unref(priv->gobj, wrapped_gobj_dispose_notify, priv);
         release_native_object(priv);
     }
 


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