fix Issue 11137 - Stack overflow on invalid output path
Merge pull request #2607 from WalterBright/fix11137

fix Issue 11137 - Stack overflow on invalid output path