Fixed thread-safe bug in th_get_pathname()