Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
do not segfault in mce_get_io_monitor_name when input devices get cha…
…nged

calling remove_input_device with "GSlist* devices" and then doing

devices = g_slist_remove(devices, iomon_id);

affects stack variable, but not what really needs to be changed.

Fix it by passing "GSlist** devices" as parameter to remove_input_device()

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
  • Loading branch information
freemangordon committed Oct 29, 2016
1 parent e376f87 commit 661b8d7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions event-input.c
Expand Up @@ -666,21 +666,21 @@ static void match_and_register_io_monitor(const gchar *filename)
EXIT:;
}

static void remove_input_device(GSList *devices, const gchar *device)
static void remove_input_device(GSList **devices, const gchar *device)
{
gconstpointer iomon_id = NULL;
GSList *list_entry = NULL;

/* Try to find a matching device I/O monitor */
list_entry = g_slist_find_custom(devices, device,
list_entry = g_slist_find_custom(*devices, device,
iomon_name_compare);

/* If we find one, obtain the iomon ID,
* remove the entry and finally unregister the I/O monitor
*/
if (list_entry != NULL) {
iomon_id = list_entry->data;
devices = g_slist_remove(devices, iomon_id);
*devices = g_slist_remove(*devices, iomon_id);
mce_unregister_io_monitor(iomon_id);
}
}
Expand All @@ -697,16 +697,16 @@ static void remove_input_device(GSList *devices, const gchar *device)
static void update_inputdevices(const gchar *device, gboolean add)
{
/* Try to find a matching touchscreen I/O monitor */
remove_input_device(touchscreen_dev_list, device);
remove_input_device(&touchscreen_dev_list, device);

/* Try to find a matching keyboard I/O monitor */
remove_input_device(keyboard_dev_list, device);
remove_input_device(&keyboard_dev_list, device);

/* Try to find a matching switch I/O monitor */
remove_input_device(switch_dev_list, device);
remove_input_device(&switch_dev_list, device);

/* Try to find a matching misc I/O monitor */
remove_input_device(misc_dev_list, device);
remove_input_device(&misc_dev_list, device);

if (add == TRUE)
match_and_register_io_monitor(device);
Expand Down

0 comments on commit 661b8d7

Please sign in to comment.