public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3729] [Ada] Exception raised on empty file in GNATprove mode Date: Tue, 21 Sep 2021 15:25:58 +0000 (GMT) [thread overview] Message-ID: <20210921152558.A5460385842E@sourceware.org> (raw) https://gcc.gnu.org/g:ea3789f6a2b868d9f440ddece64142d3a2cbcf1c commit r12-3729-gea3789f6a2b868d9f440ddece64142d3a2cbcf1c Author: Yannick Moy <moy@adacore.com> Date: Thu Jul 1 09:36:53 2021 +0200 [Ada] Exception raised on empty file in GNATprove mode gcc/ada/ * errout.adb (Get_Line_End): Do not allow the result to go past the end of the buffer. Diff: --- gcc/ada/errout.adb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 0122304da6f..c859d8c5110 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -2473,7 +2473,8 @@ package body Errout is function Get_Line_End (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr; - -- Get the source location for the end of the line in Buf for Loc + -- Get the source location for the end of the line in Buf for Loc. If + -- Loc is past the end of Buf already, return Buf'Last. function Get_Line_Start (Buf : Source_Buffer_Ptr; @@ -2515,9 +2516,9 @@ package body Errout is (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr is - Cur_Loc : Source_Ptr := Loc; + Cur_Loc : Source_Ptr := Source_Ptr'Min (Loc, Buf'Last); begin - while Cur_Loc <= Buf'Last + while Cur_Loc < Buf'Last and then Buf (Cur_Loc) /= ASCII.LF loop Cur_Loc := Cur_Loc + 1;
reply other threads:[~2021-09-21 15:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210921152558.A5460385842E@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).