[gjs/ewlsh/fix-vfunc: 10/10] Prevent unimplemented vfuncs from crashing.




commit dd2139a6f12b781ce9ff50ec46d33f7eb071a62d
Author: Evan Welsh <noreply evanwelsh com>
Date:   Sat Aug 22 18:09:22 2020 -0500

    Prevent unimplemented vfuncs from crashing.
    
    It is common for a base class to not implement a virtual
    function and leave is as NULL, this currently causes GJS
    to crash if subclasses chain up. This change makes it a
    recoverable JS-level error.
    
    Fixes #313

 gi/function.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index dccf2777..b6f6fe11 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1215,7 +1215,8 @@ init_cached_function_data (JSContext      *context,
             if (error->code != G_INVOKE_ERROR_SYMBOL_NOT_FOUND)
                 return gjs_throw_gerror(context, error);
 
-            g_clear_error(&error);
+            gjs_throw(context, "Virtual function not implemented: %s",
+                      error->message);
             return false;
         }
 


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