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