error checking tweaks

(cherry picked from commit 6ac38519b710e69a0c30eb0fe8fc5fa712168cb8)
This commit is contained in:
Taeer Bar-Yam 2024-05-09 12:41:34 -04:00 committed by Robert Hensing
parent c2159c8834
commit 48af0f9e41
5 changed files with 14 additions and 8 deletions

View file

@ -52,8 +52,9 @@ impl EvalState {
store.raw_ptr(),
)
};
context.check_err()?;
if eval_state.is_null() {
bail!("nix_state_create returned a null pointer");
panic!("nix_state_create returned a null pointer without an error");
}
Ok(EvalState {
eval_state: NonNull::new(eval_state).unwrap(),
@ -152,7 +153,7 @@ where
if unsafe { raw::GC_thread_is_registered() } != 0 {
return Ok(f());
} else {
gc_register_my_thread().unwrap();
gc_register_my_thread()?;
let r = f();
unsafe {
raw::GC_unregister_my_thread();