Skip to content

Commit 3271758

Browse files
committed
simplify code
1 parent 9e4c747 commit 3271758

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/pe/tls.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,15 @@ impl<'a> TlsData<'a> {
219219
// VA to RVA
220220
let rva = itd.start_address_of_raw_data - image_base;
221221
let size = itd.end_address_of_raw_data - itd.start_address_of_raw_data;
222+
let offset = utils::find_offset(rva as usize, sections, file_alignment, opts);
222223

223-
if let Some(offset) = utils::find_offset(rva as usize, sections, file_alignment, opts) {
224+
raw_data = offset.and_then(|offset| {
224225
if offset < bytes.len() {
225-
raw_data = (&bytes[offset..]).pread_with(0, size as usize).ok();
226+
(&bytes[offset..]).pread_with(0, size as usize).ok()
227+
} else {
228+
None
226229
}
227-
}
230+
});
228231
}
229232

230233
// Parse the index if any

0 commit comments

Comments
 (0)