ecore-wl2: Check the return value of ecore_main_fd_handler_fd_get
authorChris Michael <cpmichael@osg.samsung.com>
Thu, 30 Jun 2016 15:05:14 +0000 (11:05 -0400)
committerChris Michael <cpmichael@osg.samsung.com>
Thu, 30 Jun 2016 15:05:14 +0000 (11:05 -0400)
This patch fixes an issue where ecore_main_fd_handler_fd_get could be
returning a negative number and passing that to close() which cannot
accept negative numbers.

Fixes Coverity CID1357152

@fix

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
src/lib/ecore_wl2/ecore_wl2_dnd.c

index 993f899..b885356 100644 (file)
@@ -449,7 +449,11 @@ _ecore_wl2_dnd_del(Ecore_Wl2_Dnd_Source *source)
    if (!source) return;
    if (source->fdh)
      {
-        close(ecore_main_fd_handler_fd_get(source->fdh));
+        int fd;
+
+        fd = ecore_main_fd_handler_fd_get(source->fdh);
+        if (fd >= 0)
+          close(ecore_main_fd_handler_fd_get(source->fdh));
         ecore_main_fd_handler_del(source->fdh);
      }
    wl_data_offer_destroy(source->offer);