Commit c4ca0af4 by Nicolas Roche Committed by Pierre-Marie de Rodat

[Ada] Avoid a stack overflow in 'Value for invalid long strings

2018-06-11  Nicolas Roche  <roche@adacore.com>

gcc/ada/

	* libgnat/s-valuti.adb (Bad_Value): Ensure that we do not generate a
	stack overflow while raising a constraint error.

From-SVN: r261396
parent 972d2984
2018-06-11 Nicolas Roche <roche@adacore.com>
* libgnat/s-valuti.adb (Bad_Value): Ensure that we do not generate a
stack overflow while raising a constraint error.
2018-06-11 Eric Botcazou <ebotcazou@adacore.com>
* repinfo.ads (Rep_Value): Use a single line.
......
......@@ -39,7 +39,15 @@ package body System.Val_Util is
procedure Bad_Value (S : String) is
begin
raise Constraint_Error with "bad input for 'Value: """ & S & '"';
-- Bad_Value might be called with very long strings allocated on the
-- heap. Limit the size of the message so that we avoid creating a
-- Storage_Error during error handling.
if S'Length > 127 then
raise Constraint_Error with "bad input for 'Value: """
& S (S'First .. S'First + 127) & "...""";
else
raise Constraint_Error with "bad input for 'Value: """ & S & '"';
end if;
end Bad_Value;
----------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment