Uninitialized stack memory was being re-used in a loop.
Error in original commit from 04f81c8225
This happened to work as the same memory location was re-used
between iterations and not overwritten.
Ensure we use the first frame as filepath so we can compute the number of
leading zeros. For file validation, always test the first frame rather than
the current scene frame.
Note this only changes cases where the variable was declared inside
the for loop. To handle it outside as well is a different challenge.
Differential Revision: https://developer.blender.org/D7320