Skip to content

Commit afa4189

Browse files
committed
chore: fix unsafe in unsafe blocks lint
Enable this lint and fix the two cases where it breaks.
1 parent 524bc0e commit afa4189

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

boreal/src/compiler/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ impl Compiler {
143143
pub unsafe fn new_with_pe_signatures() -> Self {
144144
let mut this = Self::new_without_pe_module();
145145

146-
let _r = this.add_module(crate::module::Pe::new_with_signatures());
146+
let _r = this.add_module(
147+
// Safety: guaranteed by the safety contract of this function
148+
unsafe { crate::module::Pe::new_with_signatures() },
149+
);
147150

148151
this
149152
}

boreal/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#![deny(unused_lifetimes)]
5252
#![deny(unused_qualifications)]
5353
#![deny(unused_results)]
54+
#![deny(unsafe_op_in_unsafe_fn)]
5455
// Do the same for clippy
5556
#![deny(clippy::all)]
5657
#![deny(clippy::pedantic)]

boreal/src/module/pe.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,10 @@ impl Pe {
11391139
#[cfg(feature = "authenticode")]
11401140
pub unsafe fn new_with_signatures() -> Self {
11411141
Self {
1142-
token: Some(authenticode_parser::InitializationToken::new()),
1142+
token: Some(
1143+
// Safety: guaranteed by the safety contract of this function
1144+
unsafe { authenticode_parser::InitializationToken::new() },
1145+
),
11431146
}
11441147
}
11451148

0 commit comments

Comments
 (0)