diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-06-17 00:32:38 -0400 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-06-19 07:34:19 +0000 |
commit | b533df36436432def2e8c14099b0cf98f96ff839 (patch) | |
tree | 5ab8d41250ef85c0e943a72fd0d982dbc0e454f5 | |
parent | 7671253eda836193313586013e92dde3d14f5ebe (diff) | |
download | gcc-b533df36436432def2e8c14099b0cf98f96ff839.zip gcc-b533df36436432def2e8c14099b0cf98f96ff839.tar.gz gcc-b533df36436432def2e8c14099b0cf98f96ff839.tar.bz2 |
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>
-rw-r--r-- | gcc/rust/lex/rust-lex.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc index d80ce9a..b1a867b 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 |