at-spi r1104 - in trunk: . libspi



Author: liyuan
Date: Sat Sep 27 08:47:02 2008
New Revision: 1104
URL: http://svn.gnome.org/viewvc/at-spi?rev=1104&view=rev

Log:
2008-09-27  Li Yuan  <li yuan sun com>

        * libspi/collection.c: (match_states_all_p), (match_states_any_p),
        (match_roles_all_p), (match_roles_any_p), (match_roles_none_p),
        (match_interfaces_all_p), (match_interfaces_any_p),
        (match_interfaces_none_p), (match_attributes_all_p),
        (match_attributes_any_p), (match_attributes_none_p),
        (getMatchesFrom), (getMatchesInOrder), (getMatchesInBackOrder),
        (getMatchesTo), (impl_getMatches):
        Bug #527585. Fix memory leak and swapped order of some checks so that
        a NULL pointer is checked for before attempting to read from it.
        Patch from Mike Gorse.


Modified:
   trunk/ChangeLog
   trunk/libspi/collection.c

Modified: trunk/libspi/collection.c
==============================================================================
--- trunk/libspi/collection.c	(original)
+++ trunk/libspi/collection.c	Sat Sep 27 08:47:02 2008
@@ -178,7 +178,7 @@
      Accessibility_StateSeq *seq = Accessibility_StateSet_getStates (set, ev); 
      gint i;
 
-     if (seq->_length == 0 || seq == NULL)
+     if (seq == NULL || seq->_length == 0)
 	  return TRUE;
 
      chs = Accessibility_Accessible_getState (child, ev);
@@ -199,7 +199,7 @@
      Accessibility_StateSeq *seq = Accessibility_StateSet_getStates (set, ev);
      gint i;
 
-     if (seq->_length == 0 || seq == NULL)
+     if (seq == NULL || seq->_length == 0)
 	  return TRUE;
 
      chs = Accessibility_Accessible_getState (child, ev);
@@ -265,10 +265,10 @@
 
    Accessibility_Role role; 
 
-     if (roles->_length > 1) 
-	  return FALSE;
-     else if (roles->_length == 0 || roles == NULL)
+     if (roles == NULL || roles->_length == 0)
 	  return TRUE;
+     else if (roles->_length > 1) 
+	  return FALSE;
 
      role  = Accessibility_Accessible_getRole (child, ev);
 
@@ -287,7 +287,7 @@
      Accessibility_Role role; 
      int i;
 
-     if (roles->_length == 0 || roles == NULL)
+     if (roles == NULL || roles->_length == 0)
 	  return TRUE;
 
      role =  Accessibility_Accessible_getRole (child, ev);
@@ -307,7 +307,7 @@
   Accessibility_Role role ; 
      int i;
 
-     if (roles->_length == 0 || roles == NULL)
+     if (roles == NULL || roles->_length == 0)
 	  return TRUE;
 
      role =  Accessibility_Accessible_getRole (child, ev);
@@ -363,9 +363,10 @@
 
      for (i = 0; i < length; i++)
        if (!child_interface_p (obj, ifaces [i], ev)){
-	    g_free (ifaces);
+	    g_strfreev (ifaces);
 	       return FALSE;
        }
+     g_strfreev(ifaces);
      return TRUE;
 }
 
@@ -384,9 +385,10 @@
 
      for (i = 0; i < length; i++)
        if (child_interface_p (obj, ifaces [i], ev)){
-	        g_free (ifaces);
+	        g_strfreev (ifaces);
 		return TRUE;
        }
+     g_strfreev(ifaces);
      return FALSE;
 }
 
@@ -402,9 +404,12 @@
 	  return TRUE;
 
      for (i = 0; i < length; i++)
-	   if (child_interface_p (obj, ifaces [i], ev))
+	   if (child_interface_p (obj, ifaces [i], ev)){
+		g_strfreev(ifaces);
 		return FALSE;
+	   }
      
+     g_strfreev(ifaces);
      return TRUE;
 }
 
@@ -447,7 +452,7 @@
      Accessibility_AttributeSet *oa ;
      gboolean flag = FALSE;
 
-     if (attributes->_length == 0 || attributes == NULL)
+     if (attributes == NULL || attributes->_length == 0)
 	  return TRUE;
      
      oa =  Accessibility_Accessible_getAttributes (child, ev);
@@ -476,7 +481,7 @@
 
      Accessibility_AttributeSet *oa;
 
-     if (attributes->_length == 0 || attributes == NULL)
+     if (attributes == NULL || attributes->_length == 0)
 	  return TRUE;
 
      oa =  Accessibility_Accessible_getAttributes (child, ev);
@@ -497,7 +502,7 @@
      int i, k;
      Accessibility_AttributeSet *oa;
 
-     if (attributes->_length == 0 || attributes == NULL)
+     if (attributes == NULL || attributes->_length == 0)
 	  return TRUE;
 
      oa =  Accessibility_Accessible_getAttributes (child, ev);
@@ -712,7 +717,7 @@
      glong index = 
            Accessibility_Accessible_getIndexInParent (current_object, ev);
      gint kount = 0;
-
+     Accessibility_AccessibleSet *retval;
      ls = g_list_append (ls, current_object);
      mrp =  get_collection_from_servant (servant)->_mrp;;
           
@@ -726,12 +731,14 @@
                               current_object, 0, FALSE, CORBA_OBJECT_NIL, 
                               TRUE, traverse, ev);
 
-     ls = g_list_next (ls); 
+     ls = g_list_remove(ls, g_list_nth_data(ls, 0));
 
      if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
        ls = g_list_reverse (ls);
  
-     return  _accessible_list_to_set (ls, kount);
+     retval = _accessible_list_to_set (ls, kount);
+     g_list_free(ls);
+     return retval;
 }
 
 /*
@@ -793,6 +800,7 @@
   Accessibility_Accessible obj;
   MatchRulePrivate *mrp;
   gint kount = 0;
+  Accessibility_AccessibleSet *retval;
 
   ls = g_list_append (ls, current_object);
   mrp = get_collection_from_servant (servant)->_mrp;
@@ -803,12 +811,14 @@
   kount = inorder (obj, mrp, ls, 0, count, 
                    current_object, TRUE, CORBA_OBJECT_NIL, traverse, ev);
 
-  ls = g_list_next (ls);
+  ls = g_list_remove(ls, g_list_nth_data(ls, 0));
 
   if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
     ls = g_list_reverse (ls);
 
-  return _accessible_list_to_set (ls, kount); 
+  retval = _accessible_list_to_set (ls, kount); 
+  g_list_free(ls);
+  return retval;
 }
 
 /*
@@ -827,6 +837,7 @@
   Accessibility_Accessible collection;
   MatchRulePrivate *mrp;
   gint kount = 0;
+  Accessibility_AccessibleSet *retval;
 
   ls = g_list_append (ls, current_object);
   mrp = get_collection_from_servant (servant)->_mrp;
@@ -837,12 +848,14 @@
   kount = sort_order_rev_canonical (mrp, ls, 0, count, current_object, 
                                    FALSE, collection, ev);
 
-  ls = g_list_next (ls);
+  ls = g_list_remove(ls, g_list_nth_data(ls, 0));
 
   if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
     ls = g_list_reverse (ls);
 
-  return _accessible_list_to_set (ls, kount); 
+  retval = _accessible_list_to_set (ls, kount); 
+  g_list_free(ls);
+  return retval;
 }
 
 
@@ -862,6 +875,7 @@
   Accessibility_Accessible obj;
   MatchRulePrivate *mrp;
   gint kount = 0;
+  Accessibility_AccessibleSet *retval;
 
   ls = g_list_append (ls, current_object); 
   mrp =  get_collection_from_servant (servant)->_mrp;
@@ -879,13 +893,14 @@
 
   }
 
-  ls = g_list_next (ls); 
+  ls = g_list_remove(ls, g_list_nth_data(ls, 0));
    
   if (sortby != Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
     ls = g_list_reverse (ls);
 
-  return  _accessible_list_to_set (ls, kount);
-  
+  retval = _accessible_list_to_set (ls, kount);
+  g_list_free(ls);
+  return retval;
 }
 
 static Accessibility_AccessibleSet *
@@ -955,6 +970,7 @@
      Accessibility_Accessible obj;
      MatchRulePrivate *mrp;
      gint kount = 0;
+     Accessibility_AccessibleSet *retval;
     
      obj = spi_accessible_new_return (aobj, FALSE, ev);
      ls = g_list_prepend (ls, obj); 
@@ -963,12 +979,14 @@
      kount = query_exec (mrp,  sortby, ls, 0, count, 
                          obj, 0, TRUE, CORBA_OBJECT_NIL, TRUE, traverse, ev); 
 
-     ls = g_list_next (ls); 
+     ls = g_list_remove(ls, g_list_nth_data(ls, 0));
     
      if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
        ls = g_list_reverse (ls);
 
-     return  _accessible_list_to_set (ls, kount);
+     retval = _accessible_list_to_set (ls, kount);
+     g_list_free(ls);
+     return retval;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]