Fix home-dir crash
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 15 Nov 2010 10:36:21 +0000 (11:36 +0100)
committerArun Persaud <arun@nubati.net>
Thu, 18 Nov 2010 07:06:44 +0000 (23:06 -0800)
When confronted with a path name starting with ~ and not containing a /
XBoard would segfault.

xboard.c

index 2e8a773..3050105 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -7621,7 +7621,7 @@ ExpandPathName(path)
        }
        else {
          safeStrCpy(buf, s+1, sizeof(buf)/sizeof(buf[0]) );
-         *strchr(buf, '/') = 0;
+         { char *p; if(p = strchr(buf, '/')) *p = 0; }
          pwd = getpwnam(buf);
          if (!pwd)
            {