This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Ada] Wrong code in gcc/ada/a-teioed.adb causing FAIL of ACATS cxf3a01 on mipsel and ia64


Laurent GUERBY wrote:
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 <laurent@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;





looks ok 2 me


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]