Fix possible crash in _get_object_in_relation in flat_navi.
authorTomasz Olszak <t.olszak@samsung.com>
Thu, 6 Aug 2015 08:24:20 +0000 (10:24 +0200)
committerTomasz Olszak <t.olszak@samsung.com>
Thu, 6 Aug 2015 08:26:44 +0000 (10:26 +0200)
Change-Id: Ic175928e547c99521c3029dc690844f6092f5262

src/flat_navi.c

index 62fb968..4d4e01a 100644 (file)
@@ -139,21 +139,24 @@ static AtspiAccessible* _get_object_in_relation(AtspiAccessible *source, AtspiRe
       {
          DEBUG("CHECKING RELATIONS");
          relations = atspi_accessible_get_relation_set(source, NULL);
-         for (i = 0; i < relations->len; i++)
-            {
-               DEBUG("ALL RELATIONS FOUND: %d",relations->len);
-               relation = g_array_index (relations, AtspiRelation*, i);
-               type = atspi_relation_get_relation_type(relation);
-               DEBUG("RELATION:  %d",type);
-
-               if (type == search_type)
-                  {
-                     ret = atspi_relation_get_target(relation, 0);
-                     DEBUG("SEARCHED RELATION FOUND");
-                     break;
-                  }
-            }
-         g_array_free(relations, TRUE);
+         if (relations)
+           {
+              for (i = 0; i < relations->len; i++)
+                 {
+                   DEBUG("ALL RELATIONS FOUND: %d",relations->len);
+                   relation = g_array_index (relations, AtspiRelation*, i);
+                   type = atspi_relation_get_relation_type(relation);
+                   DEBUG("RELATION:  %d",type);
+
+                   if (type == search_type)
+                      {
+                         ret = atspi_relation_get_target(relation, 0);
+                         DEBUG("SEARCHED RELATION FOUND");
+                         break;
+                      }
+                 }
+              g_array_free(relations, TRUE);
+           }
       }
    return ret;
 }