diff options
author | paul <paul> | 2003-10-15 22:09:28 +0000 |
---|---|---|
committer | paul <paul> | 2003-10-15 22:09:28 +0000 |
commit | 79ad27982af1440a841298b684d94732ae07d003 (patch) | |
tree | 38396c6632528ac715d098fc15fb7c9496be0ea6 | |
parent | affe1d9c7f333e0d0373505c4a57994ab1a03822 (diff) |
2003-10-15 Paul Jakma <paul@dishone.st>
* lib/vty.c: (vty_save_cwd) dont crash if getcwd fails. try fallback
to SYSCONFDIR. Allocate cwd from the stack rather than relying on
(non-portable) getcwd() allocation (which we didnt seem to be
freeing).
-rw-r--r-- | lib/vty.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -2757,9 +2757,15 @@ vty_finish () void vty_save_cwd () { - char *cwd; + char cwd[MAXPATHLEN]; + + cwd[0] = getcwd (cwd, MAXPATHLEN); - cwd = getcwd (NULL, MAXPATHLEN); + if (!cwd) + { + chdir (SYSCONFDIR); + cwd[0] = getcwd (cwd, MAXPATHLEN); + } vty_cwd = XMALLOC (MTYPE_TMP, strlen (cwd) + 1); strcpy (vty_cwd, cwd); |