Fix dereference of NULL 97/55297/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 23 Dec 2015 02:27:20 +0000 (11:27 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 23 Dec 2015 02:27:20 +0000 (11:27 +0900)
Pointer 'resource', which is passed as 1st parameter in call to function 'wl_resource_set_implementation' at e_mod_main.c:1161, where it is dereferenced at wayland-server.c:1291, may have NULL value.

Change-Id: If0265f777d8d73e9cd59e1ff2fc6e0ef67e1da43

src/e_mod_main.c

index 95e7e3a..fb107ec 100644 (file)
@@ -1155,8 +1155,6 @@ _e_text_cb_bind_input_method(struct wl_client *client, void *data, uint32_t vers
 
    if (!input_method) return;
 
-   resource = wl_resource_create(client, &wl_input_method_interface, 1, id);
-
    if (input_method->resource)
      {
         wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
@@ -1164,10 +1162,15 @@ _e_text_cb_bind_input_method(struct wl_client *client, void *data, uint32_t vers
         return;
      }
 
+   resource = wl_resource_create(client, &wl_input_method_interface, 1, id);
+
    input_method->resource = resource;
 
-   wl_resource_set_implementation(resource, NULL, input_method,
-                                  _e_text_input_method_cb_unbind);
+   if (resource)
+     {
+        wl_resource_set_implementation(resource, NULL, input_method,
+                                       _e_text_input_method_cb_unbind);
+     }
 }
 
 static void