[gjs/gnome-3-32] gobject: Use auto-compartment on object when setting property



commit 42103be2f31685e7b0b668ab190e9fad8f5d191b
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Apr 25 14:06:35 2019 -0500

    gobject: Use auto-compartment on object when setting property
    
    When binding a property inherited from the object to another
    gobject property added in Javascript, it could happen that gjs
    crashes when setting the property.
    
    So enter a new compartment when doing this.
    
    Fixes https://gitlab.gnome.org/GNOME/gjs/issues/246

 gi/gobject.cpp | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/gi/gobject.cpp b/gi/gobject.cpp
index f9db5c94..8902dae8 100644
--- a/gi/gobject.cpp
+++ b/gi/gobject.cpp
@@ -143,6 +143,8 @@ static void gjs_object_set_gproperty(GObject* object, unsigned property_id,
     JSContext *cx = current_context();
 
     JS::RootedObject js_obj(cx, priv->wrapper());
+    JSAutoCompartment ac(cx, js_obj);
+
     if (!jsobj_set_gproperty(cx, js_obj, value, pspec))
         gjs_log_exception(cx);
 }


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