From 9a2ce2a5ad8cf9fd63462cc554b7a91da721df40 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 5 Oct 2012 20:17:54 +0200 Subject: [PATCH] vmod: don't allow to add a vmod with the name of a real mod Otherwise strange thing might ensue. Signed-off-by: Ran Benita --- src/xkbcomp/vmod.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c index ebd5371..51269be 100644 --- a/src/xkbcomp/vmod.c +++ b/src/xkbcomp/vmod.c @@ -43,6 +43,7 @@ bool HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, VModInfo *info) { xkb_mod_index_t i; + const char *name; const struct xkb_vmod *vmod; struct xkb_vmod new; @@ -51,6 +52,15 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, VModInfo *info) "Support for setting a value in a virtual_modifiers statement has been removed; " "Value ignored\n"); + name = xkb_atom_text(keymap->ctx, stmt->name); + if (ModNameToIndex(name) != XKB_MOD_INVALID) { + log_err(keymap->ctx, + "Can't add a virtual modifier named \"%s\"; " + "there is already a non-virtual modifier with this name! Ignored\n", + name); + return false; + } + darray_enumerate(i, vmod, keymap->vmods) { if (vmod->name == stmt->name) { info->available |= 1 << i;