[gjs] importer: Don't crash if we're enumerating the prototype



commit f4cf549c231ac109b3d01ac4f99c91300dc16f50
Author: Colin Walters <walters verbum org>
Date:   Thu Sep 23 17:31:23 2010 -0400

    importer: Don't crash if we're enumerating the prototype
    
    Apparently enumeration changed so that (for v in importer) now
    *also* loops over the prototype properties.  However, the code
    didn't handle this, because the _INIT case for prototype just
    stuffed JSVAL_NULL into the custom data.
    
    Handle this by simply ignoring JSVAL_NULL in ENUMERATE_NEXT, and finish
    the iteration.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=622896

 gjs/importer.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/gjs/importer.c b/gjs/importer.c
index 5f755cb..abba364 100644
--- a/gjs/importer.c
+++ b/gjs/importer.c
@@ -858,6 +858,9 @@ importer_new_enumerate(JSContext  *context,
             return JS_FALSE;
         }
 
+        if (*state_p == JSVAL_NULL) /* Iterating prototype */
+            return JS_TRUE;
+
         iter = JSVAL_TO_PRIVATE(*state_p);
 
         if (iter->index < iter->elements->len) {



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