std: Make vec::from_fn failure-safe

A recently-enabled test of this is causing valgrind failures.