Skip to content

Commit

Permalink
Avoid accidental insertion into map
Browse files Browse the repository at this point in the history
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 <powerboat9.gamer@gmail.com>
  • Loading branch information
powerboat9 authored and P-E-P committed Sep 7, 2024
1 parent 84f772c commit 14528a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gcc/rust/resolve/rust-ast-resolve-pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
Expand Down

0 comments on commit 14528a8

Please sign in to comment.