e_comp_wl_data: Fix fd leak 56/310956/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 10 May 2024 06:47:30 +0000 (15:47 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 10 May 2024 08:03:08 +0000 (17:03 +0900)
If new copy request is received in the middle of the copy operation,
previous copy operation will stop.
At this time, the fd close is missing and the fd leak occurs.

Change-Id: I03cde1b4a12b03dad2409077d2e1810b5d9813b1

src/bin/e_comp_wl_data.c

index d32d6fe14389b035a3857d51ef8fa8a83a4b055d..c408108d243bbc277fc1b1231a7de47301977c91 100644 (file)
@@ -362,7 +362,16 @@ _e_comp_wl_data_offer_cb_resource_destroy(struct wl_resource *resource)
      {
         wl_list_remove(&offer->source_destroy_listener.link);
         if (offer->source->fd_handler)
-          ecore_main_fd_handler_del(offer->source->fd_handler);
+          {
+             ecore_main_fd_handler_del(offer->source->fd_handler);
+             if (offer->fd > 0)
+               {
+                  close(offer->fd);
+                  offer->fd = 0;
+               }
+             if (offer->source->fd[0] > 0)
+               close(offer->source->fd[0]);
+          }
 
         if (wl_resource_get_version(offer->resource) < WL_DATA_OFFER_ACTION_SINCE_VERSION)
           _e_comp_wl_data_source_notify_finish(offer->source);
@@ -394,7 +403,16 @@ _e_comp_wl_data_offer_cb_source_destroy(struct wl_listener *listener, void *data
    if (!offer) return;
 
    if (offer->source && offer->source->fd_handler)
-     ecore_main_fd_handler_del(offer->source->fd_handler);
+     {
+        ecore_main_fd_handler_del(offer->source->fd_handler);
+        if (offer->fd > 0)
+          {
+             close(offer->fd);
+             offer->fd = 0;
+          }
+        if (offer->source->fd[0] > 0)
+          close(offer->source->fd[0]);
+     }
 
    offer->source = NULL;
 }