Skip to content

Commit

Permalink
Merge pull request #2692 from artichoke/lopopolo/gh-2691-unsafe-preco…
Browse files Browse the repository at this point in the history
…ndition-rest-args

Do not create a slice of rest args when none are given
  • Loading branch information
lopopolo committed Feb 11, 2024
2 parents 287b1fb + 8dd08e3 commit f84bd07
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion artichoke-backend/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ macro_rules! mrb_get_args {
args.as_mut_ptr(),
count.as_mut_ptr(),
);
std::slice::from_raw_parts(args.assume_init(), count.assume_init())
let args = args.assume_init();
let count = count.assume_init();
if args.is_null() || count == 0 {
&[]
} else {
std::slice::from_raw_parts(args, count)
}
}};
}

0 comments on commit f84bd07

Please sign in to comment.