Skip to content

Commit 09bd764

Browse files
authored
PE: Remove unwind info alignment assertion (#480)
1 parent 8e606d8 commit 09bd764

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/pe/exception.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ use crate::pe::options;
5353
use crate::pe::section_table;
5454
use crate::pe::utils;
5555

56+
/// **N**o handlers.
57+
const UNW_FLAG_NHANDLER: u8 = 0x00;
5658
/// The function has an exception handler that should be called when looking for functions that need
5759
/// to examine exceptions.
5860
const UNW_FLAG_EHANDLER: u8 = 0x01;
@@ -567,13 +569,15 @@ impl<'a> UnwindInfo<'a> {
567569
let codes_size = count_of_codes as usize * UNWIND_CODE_SIZE;
568570
let code_bytes = bytes.gread_with(&mut offset, codes_size)?;
569571

570-
// For alignment purposes, the codes array always has an even number of entries, and the
572+
// For alignment purposes, the codes array typically has an even number of entries, and the
571573
// final entry is potentially unused. In that case, the array is one longer than indicated
572574
// by the count of unwind codes field.
575+
//
576+
// Sometimes, developers decided to handy craft unwind info in their assembly forget to align
577+
// unwind infos. This is not really desirable behavior for such cases anyway.
573578
if count_of_codes % 2 != 0 {
574579
offset += 2;
575580
}
576-
debug_assert!(offset % 4 == 0);
577581

578582
let mut chained_info = None;
579583
let mut handler = None;

0 commit comments

Comments
 (0)