desktop-shell: check memory allocation in switcher_binding
authorganjing <ganjing@uniontech.com>
Tue, 28 Jul 2020 07:28:45 +0000 (15:28 +0800)
committerGanjing0224 <ganjing@uniontech.com>
Fri, 14 Aug 2020 02:00:25 +0000 (02:00 +0000)
after calling malloc() , be sure to determine whether the allocating for memory space is successful

Signed-off-by: ganjing <ganjing@uniontech.com>
desktop-shell/shell.c

index ef0696ed526732206d1b8417f95a45136aac1152..40cba183a8e15401308fbf39796331c90eb497ff 100644 (file)
@@ -4630,6 +4630,9 @@ switcher_binding(struct weston_keyboard *keyboard, const struct timespec *time,
        struct switcher *switcher;
 
        switcher = malloc(sizeof *switcher);
+       if (!switcher)
+               return;
+       
        switcher->shell = shell;
        switcher->current = NULL;
        switcher->listener.notify = switcher_handle_view_destroy;