mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
config/keybind.c: Don't overwrite the stack
This commit is contained in:
parent
a47931bba2
commit
f28319be54
2 changed files with 9 additions and 1 deletions
|
|
@ -5,6 +5,8 @@
|
||||||
#include <wlr/types/wlr_keyboard.h>
|
#include <wlr/types/wlr_keyboard.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
|
||||||
|
#define MAX_KEYSYMS 32
|
||||||
|
|
||||||
struct keybind {
|
struct keybind {
|
||||||
uint32_t modifiers;
|
uint32_t modifiers;
|
||||||
xkb_keysym_t *keysyms;
|
xkb_keysym_t *keysyms;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ struct keybind *
|
||||||
keybind_create(const char *keybind)
|
keybind_create(const char *keybind)
|
||||||
{
|
{
|
||||||
struct keybind *k = calloc(1, sizeof(struct keybind));
|
struct keybind *k = calloc(1, sizeof(struct keybind));
|
||||||
xkb_keysym_t keysyms[32];
|
xkb_keysym_t keysyms[MAX_KEYSYMS];
|
||||||
gchar **symnames = g_strsplit(keybind, "-", -1);
|
gchar **symnames = g_strsplit(keybind, "-", -1);
|
||||||
for (int i = 0; symnames[i]; i++) {
|
for (int i = 0; symnames[i]; i++) {
|
||||||
char *symname = symnames[i];
|
char *symname = symnames[i];
|
||||||
|
|
@ -46,6 +46,12 @@ keybind_create(const char *keybind)
|
||||||
}
|
}
|
||||||
keysyms[k->keysyms_len] = sym;
|
keysyms[k->keysyms_len] = sym;
|
||||||
k->keysyms_len++;
|
k->keysyms_len++;
|
||||||
|
if (k->keysyms_len == MAX_KEYSYMS) {
|
||||||
|
wlr_log(WLR_ERROR, "There are a lot of fingers involved. "
|
||||||
|
"We stopped counting at %u.", MAX_KEYSYMS);
|
||||||
|
wlr_log(WLR_ERROR, "Offending keybind was %s", keybind);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_strfreev(symnames);
|
g_strfreev(symnames);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue