f2fd08
From 69498c30904c4769de2f7b6a36eb70a8409643d0 Mon Sep 17 00:00:00 2001
f2fd08
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
f2fd08
Date: Thu, 29 Oct 2020 13:05:23 +0100
f2fd08
Subject: [PATCH 1/2] gi/object: Check property before access
f2fd08
f2fd08
... to avoid a harmless but annoying "access to undefined property"
f2fd08
warning in case the property doesn't exist (namely the first time
f2fd08
a non-introspected gtype is accessed).
f2fd08
---
f2fd08
 gi/object.cpp | 6 +++++-
f2fd08
 1 file changed, 5 insertions(+), 1 deletion(-)
f2fd08
f2fd08
diff --git a/gi/object.cpp b/gi/object.cpp
f2fd08
index e9eba75a..ee66c6f3 100644
f2fd08
--- a/gi/object.cpp
f2fd08
+++ b/gi/object.cpp
f2fd08
@@ -1599,8 +1599,12 @@ JSObject* gjs_lookup_object_constructor_from_info(JSContext* context,
f2fd08
     if (G_UNLIKELY (!in_object))
f2fd08
         return NULL;
f2fd08
 
f2fd08
+    bool found;
f2fd08
+    if (!JS_HasProperty(context, in_object, constructor_name, &found))
f2fd08
+        return NULL;
f2fd08
+
f2fd08
     JS::RootedValue value(context);
f2fd08
-    if (!JS_GetProperty(context, in_object, constructor_name, &value))
f2fd08
+    if (found && !JS_GetProperty(context, in_object, constructor_name, &value))
f2fd08
         return NULL;
f2fd08
 
f2fd08
     JS::RootedObject constructor(context);
f2fd08
-- 
f2fd08
2.28.0
f2fd08
f2fd08
f2fd08
From 23093ef99411a35d8eeedb74948e6c15ed19ba10 Mon Sep 17 00:00:00 2001
f2fd08
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
f2fd08
Date: Thu, 29 Oct 2020 15:29:59 +0100
f2fd08
Subject: [PATCH 2/2] gi/fundamental: Check property before access
f2fd08
f2fd08
... to avoid a harmless but annoying "access to undefined property"
f2fd08
warning in case the property doesn't exist (namely the first time
f2fd08
a non-introspected gtype is accessed).
f2fd08
---
f2fd08
 gi/fundamental.cpp | 6 +++++-
f2fd08
 1 file changed, 5 insertions(+), 1 deletion(-)
f2fd08
f2fd08
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
f2fd08
index 0d5d3f6d..426c7db9 100644
f2fd08
--- a/gi/fundamental.cpp
f2fd08
+++ b/gi/fundamental.cpp
f2fd08
@@ -322,8 +322,12 @@ gjs_lookup_fundamental_prototype(JSContext    *context,
f2fd08
     if (G_UNLIKELY (!in_object))
f2fd08
         return NULL;
f2fd08
 
f2fd08
+    bool found;
f2fd08
+    if (!JS_HasProperty(context, in_object, constructor_name, &found))
f2fd08
+        return nullptr;
f2fd08
+
f2fd08
     JS::RootedValue value(context);
f2fd08
-    if (!JS_GetProperty(context, in_object, constructor_name, &value))
f2fd08
+    if (found && !JS_GetProperty(context, in_object, constructor_name, &value))
f2fd08
         return NULL;
f2fd08
 
f2fd08
     JS::RootedObject constructor(context);
f2fd08
-- 
f2fd08
2.28.0
f2fd08