[gjs/wip/ptomato/mozjs38: 14/32] minijasmine: Unref context on error



commit 58f7580a5c012215129d1f87e567b981f4895923
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Jan 10 23:24:48 2017 -0800

    minijasmine: Unref context on error
    
    We have to unref the GjsContext before exiting or JS_ShutDown() will
    segfault. For convenience, stick the unref in bail_out().
    
    (This doesn't have anything to do with SpiderMonkey 38, but I noticed it
    because I broke some tests while porting.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776966

 installed-tests/minijasmine.cpp |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/installed-tests/minijasmine.cpp b/installed-tests/minijasmine.cpp
index 1e3b333..2f40ed4 100644
--- a/installed-tests/minijasmine.cpp
+++ b/installed-tests/minijasmine.cpp
@@ -35,8 +35,10 @@
 
 G_GNUC_NORETURN
 static void
-bail_out(const char *msg)
+bail_out(GjsContext *gjs_context,
+         const char *msg)
 {
+    g_object_unref(gjs_context);
     g_print("Bail out! %s\n", msg);
     exit(1);
 }
@@ -77,7 +79,7 @@ main(int argc, char **argv)
         const char *coverage_prefixes[2] = { coverage_prefix, NULL };
 
         if (!coverage_output_path) {
-            bail_out("GJS_UNIT_COVERAGE_OUTPUT is required when using GJS_UNIT_COVERAGE_PREFIX");
+            bail_out(cx, "GJS_UNIT_COVERAGE_OUTPUT is required when using GJS_UNIT_COVERAGE_PREFIX");
         }
 
         GFile *output = g_file_new_for_commandline_arg(coverage_output_path);
@@ -92,11 +94,11 @@ main(int argc, char **argv)
     success = gjs_context_eval(cx, "imports.minijasmine;", -1,
                                "<jasmine>", &code, &error);
     if (!success)
-        bail_out(error->message);
+        bail_out(cx, error->message);
 
     success = gjs_context_eval_file(cx, argv[1], &code, &error);
     if (!success)
-        bail_out(error->message);
+        bail_out(cx, error->message);
 
     /* jasmineEnv.execute() queues up all the tests and runs them
      * asynchronously. This should start after the main loop starts, otherwise
@@ -120,7 +122,7 @@ main(int argc, char **argv)
     success = gjs_context_eval(cx, start_suite_script, -1, "<jasmine-start>",
                                &code, &error);
     if (!success)
-        bail_out(error->message);
+        bail_out(cx, error->message);
 
     if (code != 0)
         g_print("# Test script failed; see test log for assertions\n");


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