monitor: fix dereference NULL pointer 84/191384/4
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 16 Oct 2018 10:46:11 +0000 (19:46 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Fri, 26 Oct 2018 00:12:12 +0000 (09:12 +0900)
Change-Id: I066c0f8dd6ea2fa8d5a157fd8baa03b73f1f9313

src/wayland-tbm-monitor-server.c

index c34b1a2..6bf415c 100644 (file)
@@ -593,6 +593,11 @@ _wayland_tbm_monitor_request_create(struct wl_client *client,
        static int id_count = 1;
 
        struct wayland_tbm_monitore_request *r = calloc(1, sizeof(struct wayland_tbm_monitore_request));
+       if (!r) {
+               WL_TBM_LOG_E("failed to alloc wayland_tbm_monitore_request")
+               return NULL;
+       }
+
        memset(r, 0 , sizeof(struct wayland_tbm_monitore_request));
 
        struct wayland_tbm_server *tbm_srv =
@@ -727,6 +732,11 @@ _wayland_tbm_monitor_impl_request_to_sever(struct wl_client *client,
        }
 
        r = _wayland_tbm_monitor_request_create(client, resource, options);
+       if (!r) {
+               wl_tbm_monitor_send_done(resource, "failed to _wayland_tbm_monitor_request_create.\n");
+               return;
+       }
+
        if (r->wait_count == 0) {
                wl_tbm_monitor_send_done(r->wl_resource, r->msg);
                _wayland_tbm_monitor_request_delete(r);