* 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).
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);