explicitly end va_list lifetime

This commit is contained in:
Folkert de Vries 2025-07-27 23:07:03 +02:00
parent 002751155d
commit 213bb87351
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -519,6 +519,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
match self.locals[mir::Local::from_usize(1 + va_list_arg_idx)] {
LocalRef::Place(va_list) => {
bx.va_end(va_list.val.llval);
// Explicitly end the lifetime of the `va_list`, this matters for LLVM.
bx.lifetime_end(va_list.val.llval, va_list.layout.size);
}
_ => bug!("C-variadic function must have a `VaList` place"),
}