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.
diff --git a/lib/vty.c b/lib/vty.c
index 2f0bd3f..39d3701 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2167,7 +2167,7 @@
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 @@
char cwd[MAXPATHLEN];
FILE *confp = NULL;
char *fullpath;
+ char *tmp = NULL;
/* If -f flag specified. */
if (config_file != NULL)
@@ -2313,9 +2314,10 @@
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 @@
fclose (confp);
host_config_set (fullpath);
+
+ if (tmp)
+ XFREE (MTYPE_TMP, fullpath);
}
/* Small utility function which output log to the VTY. */