public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7675] gccrs: Prevent invalid iterator dereference
@ 2024-01-16 17:52 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 17:52 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:45c01fae2a2afb30b0ca933e9d7b807acb167d23

commit r14-7675-g45c01fae2a2afb30b0ca933e9d7b807acb167d23
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Sat Jun 17 00:32:38 2023 -0400

    gccrs: Prevent invalid iterator dereference
    
    gcc/rust/ChangeLog:
    
            * lex/rust-lex.cc
            (Lexer::classify_keyword): Check if iterator is valid before dereferencing.
    
    Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

Diff:
---
 gcc/rust/lex/rust-lex.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index c910c7cf83a..23579e51944 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -255,11 +255,12 @@ TokenId
 Lexer::classify_keyword (const std::string &str)
 {
   auto keyword = keywords.find (str);
-  auto id = keyword->second;
 
   if (keyword == keywords.end ())
     return IDENTIFIER;
 
+  auto id = keyword->second;
+
   // We now have the expected token ID of the reserved keyword. However, some
   // keywords are reserved starting in certain editions. For example, `try` is
   // only a reserved keyword in editions >=2018. The language might gain new

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

only message in thread, other threads:[~2024-01-16 17:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 17:52 [gcc r14-7675] gccrs: Prevent invalid iterator dereference Arthur Cohen

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).