On Tue, 2009-02-17 at 16:05 -0500, Robert Dewar wrote:
> Laurent GUERBY wrote:
> 
> > Two obvious solutions: use Unsupress locally since there's already a others
> > handler or add explicit length checks.
> 
> analysis looks right, an explicit length check is more appropriate,
> better to avoid the exception.

Is the following okay to commit if it passes testing?

Thanks in advance,

Laurent

2009-02-17  Laurent GUERBY  <laur...@guerby.net>

        * a-teioed.adb (Expand): Fix Result overflow.
        
Index: a-teioed.adb
===================================================================
--- a-teioed.adb        (revision 144242)
+++ a-teioed.adb        (working copy)
@@ -84,6 +84,10 @@
                --  character has already been made, so a count of one is a
                --  no-op, and a count of zero erases a character.
 
+               if Result_Index + Count - 2 > Result'Last then
+                  raise Picture_Error;
+               end if;
+
                for J in 2 .. Count loop
                   Result (Result_Index + J - 2) := Picture (Picture_Index - 1);
                end loop;
@@ -98,6 +102,10 @@
                raise Picture_Error;
 
             when others =>
+               if Result_Index > Result'Last then
+                  raise Picture_Error;
+               end if;
+
                Result (Result_Index) := Picture (Picture_Index);
                Picture_Index := Picture_Index + 1;
                Result_Index := Result_Index + 1;





Reply via email to