summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorpaul <paul>2005-10-26 05:49:54 +0000
committerpaul <paul>2005-10-26 05:49:54 +0000
commit05865c90ab0bc95b8ca1a54c794809891666cdce (patch)
tree885eb032e62c4acd4706e27c24c7bc49aa259899 /lib/vty.c
parent0241684ea77e8aa20ad2cb3903589559f4a7b009 (diff)
2005-10-26 Paul Jakma <paul.jakma@sun.com>
* command.c: Use MTYPE_HOST, MTYPE_STRVEC. Some other fixups, including fixing some likely leaks in config_write_file. * vty.c: memory macro usage fixes. (vty_read_config) fix leak where relative config file is specified.
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 2f0bd3f6..39d3701a 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2167,7 +2167,7 @@ vty_close (struct vty *vty)
close (vty->fd);
if (vty->address)
- XFREE (0, vty->address);
+ XFREE (MTYPE_TMP, vty->address);
if (vty->buf)
XFREE (MTYPE_VTY, vty->buf);
@@ -2306,6 +2306,7 @@ vty_read_config (char *config_file,
char cwd[MAXPATHLEN];
FILE *confp = NULL;
char *fullpath;
+ char *tmp = NULL;
/* If -f flag specified. */
if (config_file != NULL)
@@ -2313,9 +2314,10 @@ vty_read_config (char *config_file,
if (! IS_DIRECTORY_SEP (config_file[0]))
{
getcwd (cwd, MAXPATHLEN);
- fullpath = XMALLOC (MTYPE_TMP,
+ tmp = XMALLOC (MTYPE_TMP,
strlen (cwd) + strlen (config_file) + 2);
- sprintf (fullpath, "%s/%s", cwd, config_file);
+ sprintf (tmp, "%s/%s", cwd, config_file);
+ fullpath = tmp;
}
else
fullpath = config_file;
@@ -2394,6 +2396,9 @@ vty_read_config (char *config_file,
fclose (confp);
host_config_set (fullpath);
+
+ if (tmp)
+ XFREE (MTYPE_TMP, fullpath);
}
/* Small utility function which output log to the VTY. */