Don't let stack pointers go out of scope before using Fixes https://gitlab.com/kicad/code/kicad/-/issues/21417