From c49c20713c422c7936626195c1d9ff3a725c3704 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 1 Aug 2018 13:33:54 -0700 Subject: [PATCH] Check for duplicate jump tables before performing any IR mutations. This isn't fixing an actual bug, but it does make `add_jt` more consistent with the other `add_*` functions. --- lib/reader/src/parser.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index 3c9cb4c56f..bef37a86fd 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -233,11 +233,12 @@ impl<'a> Context<'a> { // Allocate a new jump table. fn add_jt(&mut self, jt: JumpTable, data: JumpTableData, loc: Location) -> ParseResult<()> { + self.map.def_jt(jt, loc)?; while self.function.jump_tables.next_key().index() <= jt.index() { self.function.create_jump_table(JumpTableData::new()); } self.function.jump_tables[jt] = data; - self.map.def_jt(jt, loc) + Ok(()) } // Resolve a reference to a jump table.