fix: Do not duplicate ctx expr in check_call_opt_key!
(cherry picked from commit 86ddc63a573cd08ec19008448ec2fca33a84159e)
This commit is contained in:
parent
35803f4a30
commit
da26721bea
2 changed files with 8 additions and 7 deletions
|
|
@ -223,9 +223,9 @@ impl EvalState {
|
|||
.with_context(|| "require_attrs_select_opt: attrName contains null byte")?;
|
||||
let v2 = unsafe {
|
||||
check_call_opt_key!(raw::get_attr_byname[
|
||||
self.context,
|
||||
&mut self.context,
|
||||
v.raw_ptr(),
|
||||
self.raw_ptr(),
|
||||
self.eval_state.as_ptr(),
|
||||
attr_name.as_ptr()
|
||||
])
|
||||
}?;
|
||||
|
|
|
|||
|
|
@ -107,15 +107,16 @@ pub use check_call;
|
|||
macro_rules! check_call_opt_key {
|
||||
($f:path[$ctx:expr, $($arg:expr),*]) => {
|
||||
{
|
||||
let ret = $f($ctx.ptr(), $($arg,)*);
|
||||
if unsafe { raw::err_code($ctx.ptr()) == raw::NIX_ERR_KEY } {
|
||||
$ctx.clear();
|
||||
let ctx : &mut $crate::context::Context = $ctx;
|
||||
let ret = $f(ctx.ptr(), $($arg,)*);
|
||||
if unsafe { raw::err_code(ctx.ptr()) == raw::NIX_ERR_KEY } {
|
||||
ctx.clear();
|
||||
return Ok(None);
|
||||
}
|
||||
match $ctx.check_err() {
|
||||
match ctx.check_err() {
|
||||
Ok(_) => Ok(Some(ret)),
|
||||
Err(e) => {
|
||||
$ctx.clear();
|
||||
ctx.clear();
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue