[gjs/gnome-3-36] arg: Save exception state when releasing an array



commit 253145d6edf57334daac451654c0524a774b0252
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 4cadd3ec..e0b7a49c 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -3838,6 +3838,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]