Skip to content

Commit

Permalink
Fix: Engine enforces ffi::init usage
Browse files Browse the repository at this point in the history
  • Loading branch information
IniterWorker committed Sep 17, 2024
1 parent aca7be9 commit 334d778
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openssl/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ impl Engine {
/// ```
#[corresponds(ENGINE_new)]
pub fn new() -> Result<Engine, ErrorStack> {
ffi::init();

unsafe { cvt_p(ffi::ENGINE_new()).map(Engine) }
}

Expand All @@ -54,6 +56,9 @@ impl Engine {
/// ```
#[corresponds(ENGINE_load_builtin_engines)]
pub fn load_builtin_engines() {
ffi::init();

// TODO: not sure about the ffi::init for this one.
unsafe { ffi::ENGINE_load_builtin_engines() }
}

Expand All @@ -68,6 +73,8 @@ impl Engine {
/// ```
#[corresponds(ENGINE_by_id)]
pub fn by_id(id: &str) -> Result<Engine, ErrorStack> {
ffi::init();

let id = CString::new(id).unwrap();
unsafe { cvt_p(ffi::ENGINE_by_id(id.as_ptr())).map(Engine) }
}
Expand Down

0 comments on commit 334d778

Please sign in to comment.