public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Prevent crash in Put_Scaled
@ 2019-08-12  9:57 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-08-12  9:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bob Duff

[-- Attachment #1: Type: text/plain, Size: 290 bytes --]

This patch fixes a bug in Put_Scaled, which causes a crash when checks
are on.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-08-12  Bob Duff  <duff@adacore.com>

gcc/ada/

	* libgnat/a-tifiio.adb (Put_Scaled): Prevent AA from being
	negative, since Field is range 0 .. something.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 442 bytes --]

--- gcc/ada/libgnat/a-tifiio.adb
+++ 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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-12  9:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12  9:57 [Ada] Prevent crash in Put_Scaled Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).