summaryrefslogtreecommitdiff
path: root/gi/repo.cpp
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2023-03-05 18:26:25 +0000
committerPhilip Chimento <philip.chimento@gmail.com>2023-03-05 18:26:25 +0000
commitad36414e00d4d9c1b0160e1ec3041fd1607dcd77 (patch)
treeb9ece2e1fda25100814480aaea1c21cf0701bdd4 /gi/repo.cpp
parent12de7257e2923c5285614d51f06d751ebc0c60a8 (diff)
parent52adc35e38b2475fd6468982bb9ed31d50304f36 (diff)
downloadgjs-ad36414e00d4d9c1b0160e1ec3041fd1607dcd77.tar.gz
Merge branch 'february-maintenance' into 'master'
February maintenance See merge request GNOME/gjs!828
Diffstat (limited to 'gi/repo.cpp')
-rw-r--r--gi/repo.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 27e78b5e..20f445df 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -126,16 +126,16 @@ static bool resolve_namespace_object(JSContext* context,
JS::RootedObject gi_namespace(context,
gjs_create_ns(context, ns_name.get()));
+ JS::RootedValue override(context);
+ if (!lookup_override_function(context, ns_id, &override))
+ return false;
+
/* Define the property early, to avoid reentrancy issues if
the override module looks for namespaces that import this */
if (!JS_DefinePropertyById(context, repo_obj, ns_id, gi_namespace,
GJS_MODULE_PROP_FLAGS))
return false;
- JS::RootedValue override(context);
- if (!lookup_override_function(context, ns_id, &override))
- return false;
-
JS::RootedValue result(context);
if (!override.isUndefined() &&
!JS_CallFunctionValue (context, gi_namespace, /* thisp */
@@ -556,9 +556,12 @@ lookup_override_function(JSContext *cx,
goto fail;
}
+ // If the override module is present, it must have a callable _init(). An
+ // override module without _init() is probably unintentional. (function
+ // being undefined means there was no override module.)
if (!gjs_object_require_property(cx, module, "override module",
atoms.init(), function) ||
- !function.isObjectOrNull()) {
+ !function.isObject() || !JS::IsCallable(&function.toObject())) {
gjs_throw(cx, "Unexpected value for _init in overrides module");
goto fail;
}