elm_atspi_bridge: Prevent infinite loop in calculating navigable objects 36/305836/1
authorMaria Bialota <m.bialota@samsung.com>
Thu, 8 Feb 2024 10:46:37 +0000 (11:46 +0100)
committerMaria Białota <m.bialota@samsung.com>
Thu, 8 Feb 2024 15:25:02 +0000 (15:25 +0000)
Change-Id: I82b2e78d6875b56082b09004219f4a242b4e9e1d

src/lib/elementary/efl_ui_widget.c
src/lib/elementary/elm_atspi_bridge.c

index 364046a..d6144b9 100755 (executable)
@@ -2336,7 +2336,13 @@ elm_widget_access_info_get(const Efl_Ui_Widget *obj)
 EAPI Eo *
 elm_widget_top_get(const Eo *obj)
 {
-   Efl_Ui_Widget *parent = elm_widget_parent_get(obj);
+   Efl_Ui_Widget *parent = NULL;
+
+   if (efl_isa(obj, ELM_WIDGET_ITEM_CLASS))
+     parent = elm_object_item_widget_get(obj);
+   else
+     parent = elm_widget_parent_get(obj);
+
    if (parent)
      {
         if (!efl_isa(parent, EFL_UI_WIDGET_CLASS)) return NULL;
index 7ec6133..d6a0ce2 100644 (file)
@@ -221,6 +221,15 @@ static void _socket_ifc_create(Eldbus_Connection *conn, Eo *proxy);
 //
 
 typedef struct {
+    const void *key;
+    unsigned int current_search_size;
+    unsigned int counter;
+} cycle_detection_data;
+
+void cycle_detection_initialize(cycle_detection_data *data, const void *key);
+unsigned char cycle_detection_check_if_in_cycle(cycle_detection_data *data, const void *key);
+
+typedef struct {
      const Efl_Event_Description *desc;
      const Efl_Event_Cb callback;
 } Elm_Atspi_Bridge_Event_Handler;
@@ -5036,9 +5045,12 @@ static void *_calculate_navigable_accessible_at_point_impl(accessibility_navigat
    if (!root) return NULL;
    void *prev_root = root;
    void *return_value = NULL;
-   while(1)
-      {
 
+   cycle_detection_data cycle_detection;
+   cycle_detection_initialize(&cycle_detection, root);
+
+   while (1)
+     {
        void *target = CALL(get_object_at_point, root, x, y, coordinates_are_screen_based);
        if (!target) break;
        if (target == root || target == prev_root) break;
@@ -5048,14 +5060,18 @@ static void *_calculate_navigable_accessible_at_point_impl(accessibility_navigat
        if (CALL(object_is_proxy, target)) return target;
 
        root = target;
+
        void *relation_obj = CALL(get_object_in_relation_by_type, root, ATSPI_RELATION_CONTROLLED_BY);
        unsigned char contains = 0;
+
        if (relation_obj)
          {
            contains = CALL(object_contains, relation_obj, x, y, coordinates_are_screen_based);
            if (contains) root = relation_obj;
          }
 
+       if (cycle_detection_check_if_in_cycle(&cycle_detection, root)) return NULL;
+
        if (_accept_object(table, root))
          {
            return_value = root;
@@ -5262,12 +5278,6 @@ _directional_depth_first_search_try_non_defunct_sibling(accessibility_navigation
    return node;
 }
 
-typedef struct {
-    const void *key;
-    unsigned int current_search_size;
-    unsigned int counter;
-} cycle_detection_data;
-
 void cycle_detection_initialize(cycle_detection_data *data, const void *key)
 {
    if (!data) return;