fix Issue 11137 - Stack overflow on invalid output path

fix http://d.puremagic.com/issues/show_bug.cgi?id=11137