* gcov.c (canonicalize_name): Protect use of S_ISLNK.
authorNathan Sidwell <nathan@acm.org>
Mon, 14 Nov 2011 21:44:01 +0000 (21:44 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 14 Nov 2011 21:44:01 +0000 (21:44 +0000)
From-SVN: r181367

gcc/ChangeLog
gcc/gcov.c

index e7c6952e517d8a1dfe32bf391cccd3a30b4343d2..94661b5d61d74337fd863e243c4181153271d83d 100644 (file)
@@ -1,3 +1,7 @@
+2011-11-14  Nathan Sidwell  <nathan@acm.org>
+
+       * gcov.c (canonicalize_name): Protect use of S_ISLNK.
+
 2011-11-14  Jan Hubicka  <jh@suse.cz>
 
        * config/i386/i386.c (core cost model): Correct pasto.
index dffb827bdf78a34eb61a97f841de1a53e44f7573..c5cc0efdf1a98443a322103bafaf9e704f01c8ba 100644 (file)
@@ -1688,10 +1688,15 @@ canonicalize_name (const char *name)
        {
          /* '..', we can only elide it and the previous directory, if
             we're not a symlink.  */
-         struct stat buf;
-         
+         struct stat ATTRIBUTE_UNUSED buf;
+
          *ptr = 0;
-         if (dd_base == ptr || stat (result, &buf) || S_ISLNK (buf.st_mode))
+         if (dd_base == ptr
+#if defined (S_ISLNK)
+             /* S_ISLNK is not POSIX.1-1996.  */
+             || stat (result, &buf) || S_ISLNK (buf.st_mode)
+#endif
+             )
            {
              /* Cannot elide, or unreadable or a symlink.  */
              dd_base = ptr + 2 + slash;