summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2015-10-07 17:53:03 +0200
committerDaiki Ueno <dueno@src.gnome.org>2015-10-13 08:54:30 +0900
commit2f98dddef6b85fd25e26778e6455cd6a4aeb34af (patch)
tree572a1cc5d607c1152e93608f73920c744941dac1
parent29d7f89a609c2473b2f00efcb5760f81ae30994e (diff)
downloadcaribou-2f98dddef6b85fd25e26778e6455cd6a4aeb34af.tar.gz
xadapter: Avoid a crash when Xkl doesn't know the real xkb groups
Xkl.ConfigRec gets its layouts and variants from the _XKB_RULES_NAMES root window property which isn't specified anywhere and in fact doesn't get set under Xwayland. The group index though is accurate which means that we might end up trying to access an invalid index on the layouts or variants array and crashing. Avoid this by just lying to the caller since we can't obtain the real layout/variant names in that case. Since this only happens under Xwayland and in that case the only consumer of this API is gnome-shell which ends up not using the names, this should be safe. https://bugzilla.gnome.org/show_bug.cgi?id=756194
-rw-r--r--libcaribou/xadapter.vala13
1 files changed, 11 insertions, 2 deletions
diff --git a/libcaribou/xadapter.vala b/libcaribou/xadapter.vala
index e786c66..22858b7 100644
--- a/libcaribou/xadapter.vala
+++ b/libcaribou/xadapter.vala
@@ -301,8 +301,17 @@ namespace Caribou {
out string variant_name) {
Xkl.ConfigRec config_rec = new Xkl.ConfigRec ();
config_rec.get_from_server (this.xkl_engine);
- group_name = config_rec.layouts[this.group];
- variant_name = config_rec.variants[this.group];
+
+ if (this.group < config_rec.layouts.length)
+ group_name = config_rec.layouts[this.group];
+ else
+ group_name = "";
+
+ if (this.group < config_rec.variants.length)
+ variant_name = config_rec.variants[this.group];
+ else
+ variant_name = "";
+
if (variant_name == null)
variant_name = "";