From 04a697502fbb3a69fe5dbeb0b3babf6f1e67711f Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Mon, 9 Jan 2023 23:02:53 +0800 Subject: Also check ttype_index when using SJLJ --- library/std/src/personality/dwarf/eh.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'library/std/src') diff --git a/library/std/src/personality/dwarf/eh.rs b/library/std/src/personality/dwarf/eh.rs index e7bd700b8b8..1e71da95a30 100644 --- a/library/std/src/personality/dwarf/eh.rs +++ b/library/std/src/personality/dwarf/eh.rs @@ -121,13 +121,21 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result let mut idx = ip; loop { let cs_lpad = reader.read_uleb128(); - let cs_action = reader.read_uleb128(); + let cs_action_entry = reader.read_uleb128(); idx -= 1; if idx == 0 { // Can never have null landing pad for sjlj -- that would have // been indicated by a -1 call site index. let lpad = (cs_lpad + 1) as usize; - return Ok(interpret_cs_action(cs_action, lpad)); + if cs_action_entry == 0 { + return Ok(interpret_cs_action(0, lpad)); + } else { + let action_record = + (action_table as *mut u8).offset(cs_action_entry as isize - 1); + let mut action_reader = DwarfReader::new(action_record); + let ttype_index = action_reader.read_sleb128(); + return Ok(interpret_cs_action(ttype_index as u64, lpad)); + } } } } -- cgit 1.4.1-3-g733a5