[gjs/wip/ptomato/mozjs38: 9/29] fundamental: Don't trace uninitialized memory



commit dc38a26ae80c991219081acc4e63b610d198b90c
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Feb 5 21:09:27 2017 -0800

    fundamental: Don't trace uninitialized memory
    
    This was tracing both fundamental instances and prototypes. Only the
    prototype holds a reference to the constructor name which needs to be
    traced; in the instance case, we were just tracing random memory.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776966

 gi/fundamental.cpp |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 9970328..0d23978 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -513,9 +513,9 @@ static void
 fundamental_trace(JSTracer *tracer,
                   JSObject *obj)
 {
-    Fundamental *priv = reinterpret_cast<Fundamental *>(JS_GetPrivate(obj));
-    if (priv == NULL)
-        return;
+    auto priv = static_cast<Fundamental *>(JS_GetPrivate(obj));
+    if (priv == nullptr || priv->prototype != nullptr)
+        return;  /* Only prototypes need tracing */
 
     JS_CallHeapIdTracer(tracer, &priv->constructor_name,
                         "Fundamental::constructor_name");


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