From 14528a8cf094ac4bc79a86d75d409e9afebe37ff Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Thu, 5 Sep 2024 19:44:55 -0400 Subject: [PATCH] Avoid accidental insertion into map gcc/rust/ChangeLog: * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::check_bindings_consistency): Check if outer_bindings_map contains an entry before indexing. Signed-off-by: Owen Avery --- gcc/rust/resolve/rust-ast-resolve-pattern.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-pattern.cc b/gcc/rust/resolve/rust-ast-resolve-pattern.cc index bfa6e3c4dfef..d0e5f2fa9ef9 100644 --- a/gcc/rust/resolve/rust-ast-resolve-pattern.cc +++ b/gcc/rust/resolve/rust-ast-resolve-pattern.cc @@ -330,7 +330,8 @@ PatternDeclaration::check_bindings_consistency ( if (!ident_is_outer_bound && !missing_bindings.count (ident)) missing_bindings.insert ({ident, inner_info}); - else if (outer_bindings_map[ident] != inner_info + else if (outer_bindings_map.count (ident) + && outer_bindings_map[ident] != inner_info && !inconsistent_bindings.count (ident)) inconsistent_bindings.insert ({ident, inner_info}); }