From 18ba4b0dbd971fc879c8db3cbe50726c8bd7c25e Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Mon, 12 Aug 2019 09:01:14 +0000 Subject: [PATCH] [Ada] Prevent crash in Put_Scaled This patch fixes a bug in Put_Scaled, which causes a crash when checks are on. 2019-08-12 Bob Duff gcc/ada/ * libgnat/a-tifiio.adb (Put_Scaled): Prevent AA from being negative, since Field is range 0 .. something. From-SVN: r274300 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/libgnat/a-tifiio.adb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1bf7e6da5d3..97f31414639 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-08-12 Bob Duff + + * libgnat/a-tifiio.adb (Put_Scaled): Prevent AA from being + negative, since Field is range 0 .. something. + 2019-08-12 Bob Duff * doc/gnat_ugn/gnat_utility_programs.rst (gnatmetric, gnatpp, diff --git a/gcc/ada/libgnat/a-tifiio.adb b/gcc/ada/libgnat/a-tifiio.adb index 1c817ea8a24..d0486460ecd 100644 --- a/gcc/ada/libgnat/a-tifiio.adb +++ b/gcc/ada/libgnat/a-tifiio.adb @@ -560,7 +560,7 @@ package body Ada.Text_IO.Fixed_IO is E : Integer) is pragma Assert (E >= -Max_Digits); - AA : constant Field := E + A; + AA : constant Field := Integer'Max (E + A, 0); N : constant Natural := (AA + Max_Digits - 1) / Max_Digits + 1; Q : array (0 .. N - 1) of Int64 := (others => 0); -- 2.30.2