--- a/mercurial/osutil.c Wed Sep 10 13:52:33 2008 +0200 +++ b/mercurial/osutil.c Wed Sep 10 22:37:07 2008 +0200 @@ -255,7 +255,8 @@ #ifdef AT_SYMLINK_NOFOLLOW dfd = open(path, O_RDONLY); - dir = fdopendir(dfd); + if (dfd != -1) + dir = fdopendir(dfd); #else dir = opendir(path); dfd = -1;