[gnome-shell] signalTracker: Correctly guard against invalid GObject.ConnectFlags
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] signalTracker: Correctly guard against invalid GObject.ConnectFlags
- Date: Wed, 6 Jul 2022 17:12:32 +0000 (UTC)
commit 371da8d39423dad6dab774a39fefe895239c7e16
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Jul 6 17:55:46 2022 +0200
signalTracker: Correctly guard against invalid GObject.ConnectFlags
We considered any ConnectFlag value major than SWAPPED as invalid, while
it's technically not fully true as we need to ensure that the passed
value is respecting the whole flags mask.
In fact, per se SWAPPED|AFTER (> SWAPPED) is a valid value (even if we
don't support the AFTER value).
But this makes the check more future-proof.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2366>
js/misc/signalTracker.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/js/misc/signalTracker.js b/js/misc/signalTracker.js
index 9f8a9a70f1..30de94e990 100644
--- a/js/misc/signalTracker.js
+++ b/js/misc/signalTracker.js
@@ -184,16 +184,18 @@ function connectObject(thisObj, ...args) {
return [signalName, handler, 0, arg, ...rest];
const flags = arg;
- if (flags > GObject.ConnectFlags.SWAPPED)
+ let flagsMask = 0;
+ Object.values(GObject.ConnectFlags).forEach(v => (flagsMask |= v));
+ if (!(flags & flagsMask))
throw new Error(`Invalid flag value ${flags}`);
- if (flags === GObject.ConnectFlags.SWAPPED)
+ if (flags & GObject.ConnectFlags.SWAPPED)
throw new Error('Swapped signals are not supported');
return [signalName, handler, flags, ...rest];
};
const connectSignal = (emitter, signalName, handler, flags) => {
const isGObject = emitter instanceof GObject.Object;
- const func = flags === GObject.ConnectFlags.AFTER && isGObject
+ const func = (flags & GObject.ConnectFlags.AFTER) && isGObject
? 'connect_after'
: 'connect';
const emitterProto = isGObject
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]