e_devicemgr: fix the memory leak detected by static analysis tool 39/284139/1
authorduna.oh <duna.oh@samsung.com>
Mon, 7 Nov 2022 08:20:01 +0000 (17:20 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 10 Nov 2022 09:43:41 +0000 (18:43 +0900)
Change-Id: I9733fb3941c67d6975f2d1572e0ecebacb86db63

src/bin/e_devicemgr_wl.c

index 55598f5..6e09a3e 100644 (file)
@@ -154,6 +154,7 @@ e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev)
              if (!res)
                  {
                   DMERR("Could not create tizen_input_device resource");
+                  wl_client_post_no_memory(wc);
                   break;
                 }
 
@@ -161,6 +162,8 @@ e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev)
              if (!device_user_data)
                {
                   DMERR("Failed to allocate memory for input device user data\n");
+                  wl_client_post_no_memory(wc);
+                  wl_resource_destroy(res);
                   break;
                }
              device_user_data->dev = dev;
@@ -579,6 +582,7 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version,
      {
         DMERR("Could not create tizen_input_device_manager_interface resource: %m");
         wl_client_post_no_memory(client);
+        E_FREE(mgr_data);
         return;
      }
 
@@ -607,12 +611,15 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version,
              if (!device_res)
                {
                   DMERR("Could not create tizen_input_device resource: %m");
+                  wl_client_post_no_memory(client);
                   return;
                }
              device_user_data = E_NEW(E_Devicemgr_Input_Device_User_Data, 1);
              if (!device_user_data)
                {
                   DMERR("Failed to allocate memory for input device user data\n");
+                  wl_client_post_no_memory(client);
+                  wl_resource_destroy(device_res);
                   return;
                }
              device_user_data->dev = dev;