Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transformer):
NonEmptyStack::push
write value before updating c…
…ursor (#6169) `NonEmptyStack::push` was previously updating `cursor` before writing the value to stack. This could be UB if the type `T` is `Drop`, and writing the value panicked - as then `drop` would attempt to drop an uninitialized `T`. I think `ptr::write` is infallible (can't panic), so it shouldn't matter. But *maybe* in debug mode it can panic if some invariant is broken (e.g. pointer not aligned). So play it safe and write the value first and update the cursor after.
- Loading branch information