nullpo-head / WSL-Hello-sudo

Let's sudo by face recognition of Windows Hello on Windows Subsystem for Linux (WSL). It runs on both WSL 1 and WSL 2. This is a PAM module for Linux on WSL.
MIT License
1.22k stars 46 forks source link

Fix warning that pointer doesn't outlive temporary CString #23

Closed mfenniak closed 3 years ago

mfenniak commented 3 years ago

Fixes a warning that auth.rs is retrieving the inner pointer of a temporary CString; extends the life of the CString throughout theget_user function.

warning: getting the inner pointer of a temporary `CString`
  --> src/auth.rs:53:63
   |
53 |         Some(prompt_str) => CString::new(prompt_str).unwrap().as_ptr(),
   |                             --------------------------------- ^^^^^^ this pointer will be invalid
   |                             |
   |                             this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
   |
   = note: `#[warn(temporary_cstring_as_ptr)]` on by default
   = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
   = help: for more information, see https://doc.rust-lang.org/reference/destructors.html
nullpo-head commented 3 years ago

Hi @mfenniak , thanks for catching this!