Add check for offset being negative in functins which have offset
authorPadraig O'Briain <padraigo@src.gnome.org>
Wed, 20 Feb 2002 17:18:01 +0000 (17:18 +0000)
committerPadraig O'Briain <padraigo@src.gnome.org>
Wed, 20 Feb 2002 17:18:01 +0000 (17:18 +0000)
* atk/atktext.c:
Add check for offset being negative in functins which have offset
parameter and return immediately if so.

ChangeLog
atk/atktext.c

index 253c6cc..65d5b15 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-02-20  Padraig O'Briain  <padraig.obriain@sun.com>
+
+       * atk/atktext.c:
+       Add check for offset being negative in functions which have offset
+       parameter and return immediately if so.
+
 2002-02-15  Padraig O'Briain  <padraig.obriain@sun.com>
 
        * atk/atkcomponent.h:
index ff811bb..4d8378c 100755 (executable)
@@ -157,6 +157,9 @@ atk_text_get_text (AtkText      *text,
 
   iface = ATK_TEXT_GET_IFACE (text);
 
+  if (start_offset < 0 || end_offset < 0)
+    return NULL;
+
   if (iface->get_text)
     return (*(iface->get_text)) (text, start_offset, end_offset);
   else
@@ -180,6 +183,9 @@ atk_text_get_character_at_offset (AtkText      *text,
 
   g_return_val_if_fail (ATK_IS_TEXT (text), (gunichar) 0);
 
+  if (offset < 0)
+    return (gunichar) 0;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_character_at_offset)
@@ -258,6 +264,9 @@ atk_text_get_text_after_offset (AtkText          *text,
   else
     real_end_offset = &local_end_offset;
 
+  if (offset < 0)
+    return NULL;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_text_after_offset)
@@ -343,6 +352,9 @@ atk_text_get_text_at_offset (AtkText          *text,
   else
     real_end_offset = &local_end_offset;
 
+  if (offset < 0)
+    return NULL;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_text_at_offset)
@@ -426,6 +438,9 @@ atk_text_get_text_before_offset (AtkText          *text,
   else
     real_end_offset = &local_end_offset;
 
+  if (offset < 0)
+    return NULL;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_text_before_offset)
@@ -502,17 +517,18 @@ atk_text_get_character_extents (AtkText *text,
   else
     real_height = &local_height;
 
+  *real_x = 0;
+  *real_y = 0;
+  *real_width = 0;
+  *real_height = 0;
+
+  if (offset < 0)
+    return;
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_character_extents)
     (*(iface->get_character_extents)) (text, offset, real_x, real_y, real_width, real_height, coords);
-  else
-    {
-      *real_x = 0;
-      *real_y = 0;
-      *real_width = 0;
-      *real_height = 0;
-    }
 }
 
 /**
@@ -553,6 +569,9 @@ atk_text_get_run_attributes (AtkText          *text,
   else
     real_end_offset = &local_end_offset;
 
+  if (offset < 0)
+    return NULL;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_run_attributes)