fixed a segv bug when handling symlinks.