[gjs/april-maintenance: 3/5] arg: Save exception state when releasing an array



commit 76e7f29fc53120c04c2e6862655d792d13274855
Author: Philip Chimento <philip chimento gmail com>
Date:   Thu Apr 30 21:43:05 2020 -0700

    arg: Save exception state when releasing an array
    
    In this loop, if an early element failed to release, then releasing
    subsequent elements could call JSAPI functions with an exception already
    pending. JS::AutoSaveExceptionState should do what we want here:
    temporarily clear the exception, then put it back at the end of the
    scope unless another exception was thrown.

 gi/arg.cpp | 1 +
 1 file changed, 1 insertion(+)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index abbb2ab6..cffd02e6 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -3834,6 +3834,7 @@ bool gjs_g_argument_release_out_array(JSContext* context, GITransfer transfer,
         type_needs_out_release(param_type, type_tag)) {
         for (i = 0; i < length; i++) {
             elem.v_pointer = array[i];
+            JS::AutoSaveExceptionState saved_exc(context);
             if (!gjs_g_arg_release_internal(context,
                                             GI_TRANSFER_EVERYTHING,
                                             param_type,


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