ecore_main: Check for the valid flag 73/168873/2
authorMyoungwoon Roy, Kim <myoungwoon.kim@samsung.com>
Wed, 31 Jan 2018 09:04:09 +0000 (18:04 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 1 Feb 2018 06:27:44 +0000 (06:27 +0000)
Summary:
This patch checks for the valid Ecore_Fd_Handler_Flags.
The flags should be checked like previous verion because
There are no default handlings in case of out of Ecore_Fd_Handler enum values in other funcs.

Test Plan: Execute a test case

Reviewers: cedric, raster, jpeg, stefan, Jaehyun_Cho

Differential Revision: https://phab.enlightenment.org/D5775

Change-Id: I11476f4d6c445fb071de0017fa6f2f9f63acce31

src/lib/ecore/ecore_main.c
src/tests/ecore/ecore_test_ecore.c

index bb0321d..e3a9bdb 100644 (file)
@@ -1396,7 +1396,7 @@ _ecore_main_fd_handler_add(Eo                    *obj,
    DBG("_ecore_main_fd_handler_add");
    Ecore_Fd_Handler *fdh = NULL;
 
-   if ((fd < 0) || (!func)) return NULL;
+   if ((fd < 0) || (flags == 0) || (!func)) return NULL;
 
    fdh = ecore_fd_handler_calloc(1);
    if (!fdh) return NULL;
index 89f3c0d..3fd89a9 100644 (file)
@@ -269,6 +269,32 @@ START_TEST(ecore_test_ecore_main_loop_fd_handler)
 }
 END_TEST
 
+START_TEST(ecore_test_ecore_main_loop_fd_handler_valid_flags)
+{
+   Ecore_Fd_Handler *fd_handler;
+   int comm[2];
+   int ret;
+
+   ret = ecore_init();
+   fail_if(ret < 1);
+
+   ret = pipe(comm);
+   fail_if(ret != 0);
+
+   fd_handler = ecore_main_fd_handler_add
+     (comm[0], 0, _fd_handler_cb, NULL, NULL, NULL);
+   fail_if(fd_handler != NULL);
+
+   if (fd_handler)
+          ecore_main_fd_handler_del(fd_handler);
+
+   close(comm[0]);
+   close(comm[1]);
+
+   ecore_shutdown();
+}
+END_TEST
+
 static void
 _eo_read_cb(void *data, const Efl_Event *info EINA_UNUSED)
 {
@@ -897,6 +923,7 @@ void ecore_test_ecore(TCase *tc)
    tcase_add_test(tc, ecore_test_ecore_main_loop_idle_exiter);
    tcase_add_test(tc, ecore_test_ecore_main_loop_timer);
    tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler);
+   tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler_valid_flags);
    tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler_activate_modify);
    tcase_add_test(tc, ecore_test_ecore_main_loop_event);
 #if 0