This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

allow for getpwd() failure


We'd crash instead of doing something sensible.

I'm pretty sure this is a regression.

Bootstrapped & tested on powerpc-darwin, and checked that if getpwd()
fails GCC no longer crashes.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-nocwd.patch===========================
2005-01-04  Geoffrey Keating  <geoffk@apple.com>

	* toplev.c (get_src_pwd): Handle failure of getpwd().

Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.935
diff -u -p -u -p -r1.935 toplev.c
--- toplev.c	18 Dec 2004 06:38:24 -0000	1.935
+++ toplev.c	4 Jan 2005 23:25:08 -0000
@@ -449,7 +449,11 @@ const char *
 get_src_pwd (void)
 {
   if (! src_pwd)
-    src_pwd = getpwd ();
+    {
+      src_pwd = getpwd ();
+      if (!src_pwd)
+	src_pwd = ".";
+    }
 
    return src_pwd;
 }
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]