[gjs/ewlsh/fix-null-pointers] Prevent passing null pointers when not nullable.




commit a7a3a966a6aff687630f0767853c33779b92de34
Author: Evan Welsh <noreply evanwelsh com>
Date:   Thu Oct 1 03:02:15 2020 -0500

    Prevent passing null pointers when not nullable.
    
    The arg-cache marshaller for null (pointers) doesn't check if the argument is nullable. This is a 
regression introduced by the arg-cache that can cause segfaults in functions such as GLib.str_hash.

 gi/arg-cache.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index 9107deaa..ad8b3c99 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -372,11 +372,10 @@ static bool gjs_marshal_caller_allocates_in(JSContext*, GjsArgumentCache* self,
 }
 
 GJS_JSAPI_RETURN_CONVENTION
-static bool gjs_marshal_null_in_in(JSContext*, GjsArgumentCache*,
+static bool gjs_marshal_null_in_in(JSContext* cx, GjsArgumentCache* self,
                                    GjsFunctionCallState*, GIArgument* arg,
                                    JS::HandleValue) {
-    gjs_arg_unset<void*>(arg);
-    return true;
+    return self->handle_nullable(cx, arg);
 }
 
 GJS_JSAPI_RETURN_CONVENTION


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