fix infinite loop on invalid path (fix #47)