@@ -95,17 +95,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
9595 return Ok ( EHAction :: None ) ;
9696 } else {
9797 let lpad = lpad_base + cs_lpad;
98- if cs_action_entry == 0 {
99- return Ok ( interpret_cs_action ( 0 , lpad) ) ;
100- } else {
101- let action_record =
102- ( action_table as * mut u8 ) . offset ( cs_action_entry as isize - 1 ) ;
103- let mut action_reader = DwarfReader :: new ( action_record) ;
104- let ttype_index = action_reader. read_sleb128 ( ) ;
105- // Normally, if ttype_index < 0, meaning the catch type is exception specification.
106- // Since we only care about if ttype_index is zero, so casting ttype_index to u64 makes sense.
107- return Ok ( interpret_cs_action ( ttype_index as u64 , lpad) ) ;
108- }
98+ return Ok ( interpret_cs_action ( action_table as * mut u8 , cs_action_entry, lpad) ) ;
10999 }
110100 }
111101 }
@@ -129,28 +119,31 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
129119 // Can never have null landing pad for sjlj -- that would have
130120 // been indicated by a -1 call site index.
131121 let lpad = ( cs_lpad + 1 ) as usize ;
132- if cs_action_entry == 0 {
133- return Ok ( interpret_cs_action ( 0 , lpad) ) ;
134- } else {
135- let action_record =
136- ( action_table as * mut u8 ) . offset ( cs_action_entry as isize - 1 ) ;
137- let mut action_reader = DwarfReader :: new ( action_record) ;
138- let ttype_index = action_reader. read_sleb128 ( ) ;
139- return Ok ( interpret_cs_action ( ttype_index as u64 , lpad) ) ;
140- }
122+ return Ok ( interpret_cs_action ( action_table as * mut u8 , cs_action_entry, lpad) ) ;
141123 }
142124 }
143125 }
144126}
145127
146- fn interpret_cs_action ( cs_action : u64 , lpad : usize ) -> EHAction {
147- if cs_action == 0 {
128+ unsafe fn interpret_cs_action (
129+ action_table : * mut u8 ,
130+ cs_action_entry : u64 ,
131+ lpad : usize ,
132+ ) -> EHAction {
133+ if cs_action_entry == 0 {
148134 // If cs_action is 0 then this is a cleanup (Drop::drop). We run these
149135 // for both Rust panics and foreign exceptions.
150136 EHAction :: Cleanup ( lpad)
151137 } else {
152- // Stop unwinding Rust panics at catch_unwind.
153- EHAction :: Catch ( lpad)
138+ let action_record = ( action_table as * mut u8 ) . offset ( cs_action_entry as isize - 1 ) ;
139+ let mut action_reader = DwarfReader :: new ( action_record) ;
140+ let ttype_index = action_reader. read_sleb128 ( ) ;
141+ if ttype_index == 0 {
142+ EHAction :: Cleanup ( lpad)
143+ } else {
144+ // Stop unwinding Rust panics at catch_unwind.
145+ EHAction :: Catch ( lpad)
146+ }
154147 }
155148}
156149
0 commit comments