mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-24 07:02:30 +01:00
WPrefs: fix NULL pointer handling when getting the Modifiers (Coverity #50200)
As pointed by Coverity, the allocated value returned by XGetModifierMapping is assumed to be non-NULL everywhere except when releasing it. Removed this last check (useless) and added a little check at the beginning to avoid an (improbable) crash. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
8eb6c82231
commit
266d9a2945
@@ -119,7 +119,7 @@ static void x_reset_modifier_mapping(Display * display)
|
||||
int super_bit = 0;
|
||||
int alt_bit = 0;
|
||||
int mode_bit = 0;
|
||||
XModifierKeymap *x_modifier_keymap = XGetModifierMapping(display);
|
||||
XModifierKeymap *x_modifier_keymap;
|
||||
|
||||
#define modwarn(name,old,other) \
|
||||
wwarning ("%s (0x%x) generates %s, which is generated by %s.", \
|
||||
@@ -155,6 +155,12 @@ static void x_reset_modifier_mapping(Display * display)
|
||||
else \
|
||||
old = modifier_index;
|
||||
|
||||
x_modifier_keymap = XGetModifierMapping(display);
|
||||
if (x_modifier_keymap == NULL) {
|
||||
wwarning("XGetModifierMapping returned NULL, there is no modifiers or no memory.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
mkpm = x_modifier_keymap->max_keypermod;
|
||||
for (modifier_index = 0; modifier_index < 8; modifier_index++)
|
||||
for (modifier_key = 0; modifier_key < mkpm; modifier_key++) {
|
||||
@@ -270,8 +276,7 @@ static void x_reset_modifier_mapping(Display * display)
|
||||
AltIndex = alt_bit;
|
||||
ModeIndex = mode_bit;
|
||||
|
||||
if (x_modifier_keymap != NULL)
|
||||
XFreeModifiermap(x_modifier_keymap);
|
||||
XFreeModifiermap(x_modifier_keymap);
|
||||
}
|
||||
|
||||
int ModifierFromKey(Display * dpy, const char *key)
|
||||
|
||||
Reference in New Issue
Block a user