aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent GUERBY <laurent@guerby.net>2005-04-16 07:21:58 +0000
committerLaurent Guerby <guerby@gcc.gnu.org>2005-04-16 07:21:58 +0000
commit159921c0227cda0a6279b1ce3eaa673a885b3839 (patch)
treed0971f5a0a3323f5bd3c88b8e6859cebfe814989
parent83eba8781a1f4d0f55a194e2b02d89c8580120bc (diff)
downloadgcc-159921c0227cda0a6279b1ce3eaa673a885b3839.zip
gcc-159921c0227cda0a6279b1ce3eaa673a885b3839.tar.gz
gcc-159921c0227cda0a6279b1ce3eaa673a885b3839.tar.bz2
re PR ada/18847 ([4.0 only] ACATS cxa5012 SEGV on on x86_64)
2005-04-16 Laurent GUERBY <laurent@guerby.net> PR ada/18847 * a-nudira.adb (Value): Check for valid string. * a-nuflra.adb (Value): Likewise. From-SVN: r98223
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/a-nudira.adb15
-rw-r--r--gcc/ada/a-nuflra.adb21
3 files changed, 35 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 8c37875..06bf37b 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-16 Laurent GUERBY <laurent@guerby.net>
+
+ PR ada/18847
+ * a-nudira.adb (Value): Check for valid string.
+ * a-nuflra.adb (Value): Likewise.
+
2005-04-11 Richard Sandiford <rsandifo@redhat.com>
* lang.opt: Refer to the GCC internals documentation instead of c.opt.
diff --git a/gcc/ada/a-nudira.adb b/gcc/ada/a-nudira.adb
index f3ef91a..1b91d89 100644
--- a/gcc/ada/a-nudira.adb
+++ b/gcc/ada/a-nudira.adb
@@ -229,25 +229,34 @@ package body Ada.Numerics.Discrete_Random is
-----------
function Value (Coded_State : String) return State is
+ Last : constant Natural := Coded_State'Last;
Start : Positive := Coded_State'First;
Stop : Positive := Coded_State'First;
Outs : State;
begin
- while Coded_State (Stop) /= ',' loop
+ while Stop <= Last and then Coded_State (Stop) /= ',' loop
Stop := Stop + 1;
end loop;
+ if Stop > Last then
+ raise Constraint_Error;
+ end if;
+
Outs.X1 := Int'Value (Coded_State (Start .. Stop - 1));
Start := Stop + 1;
loop
Stop := Stop + 1;
- exit when Coded_State (Stop) = ',';
+ exit when Stop > Last or else Coded_State (Stop) = ',';
end loop;
+ if Stop > Last then
+ raise Constraint_Error;
+ end if;
+
Outs.X2 := Int'Value (Coded_State (Start .. Stop - 1));
- Outs.Q := Int'Value (Coded_State (Stop + 1 .. Coded_State'Last));
+ Outs.Q := Int'Value (Coded_State (Stop + 1 .. Last));
Outs.P := Outs.Q * 2 + 1;
Outs.FP := Flt (Outs.P);
Outs.Scl := (RstL - RstF + 1.0) / (Flt (Outs.P) * Flt (Outs.Q));
diff --git a/gcc/ada/a-nuflra.adb b/gcc/ada/a-nuflra.adb
index 14d7459..70b90b8 100644
--- a/gcc/ada/a-nuflra.adb
+++ b/gcc/ada/a-nuflra.adb
@@ -256,33 +256,46 @@ package body Ada.Numerics.Float_Random is
-----------
function Value (Coded_State : String) return State is
+ Last : constant Natural := Coded_State'Last;
Start : Positive := Coded_State'First;
Stop : Positive := Coded_State'First;
Outs : State;
begin
- while Coded_State (Stop) /= ',' loop
+ while Stop <= Last and then Coded_State (Stop) /= ',' loop
Stop := Stop + 1;
end loop;
+ if Stop > Last then
+ raise Constraint_Error;
+ end if;
+
Outs.X1 := Int'Value (Coded_State (Start .. Stop - 1));
Start := Stop + 1;
loop
Stop := Stop + 1;
- exit when Coded_State (Stop) = ',';
+ exit when Stop > Last or else Coded_State (Stop) = ',';
end loop;
+ if Stop > Last then
+ raise Constraint_Error;
+ end if;
+
Outs.X2 := Int'Value (Coded_State (Start .. Stop - 1));
Start := Stop + 1;
loop
Stop := Stop + 1;
- exit when Coded_State (Stop) = ',';
+ exit when Stop > Last or else Coded_State (Stop) = ',';
end loop;
+ if Stop > Last then
+ raise Constraint_Error;
+ end if;
+
Outs.P := Int'Value (Coded_State (Start .. Stop - 1));
- Outs.Q := Int'Value (Coded_State (Stop + 1 .. Coded_State'Last));
+ Outs.Q := Int'Value (Coded_State (Stop + 1 .. Last));
Outs.X := Euclid (Outs.P, Outs.Q);
Outs.Scl := 1.0 / (Flt (Outs.P) * Flt (Outs.Q));