summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/command.c25
-rw-r--r--lib/command.h1
-rw-r--r--lib/csv.c18
-rw-r--r--lib/plist.c5
-rw-r--r--lib/prefix.c14
-rw-r--r--lib/prefix.h1
-rw-r--r--lib/routemap.c32
7 files changed, 38 insertions, 58 deletions
diff --git a/lib/command.c b/lib/command.c
index 510699f91b..6467fb7185 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -294,27 +294,6 @@ cmd_free_strvec (vector v)
vector_free (v);
}
-char *
-cmd_concat_strvec (vector v)
-{
- size_t strsize = 0;
- for (unsigned int i = 0; i < vector_active (v); i++)
- if (vector_slot (v, i))
- strsize += strlen ((char *) vector_slot (v, i)) + 1;
-
- if (strsize == 0)
- return XSTRDUP (MTYPE_TMP, "");
-
- char *concatenated = calloc (sizeof (char), strsize);
- for (unsigned int i = 0; i < vector_active (v); i++)
- {
- strlcat (concatenated, (char *) vector_slot (v, i), strsize);
- strlcat (concatenated, " ", strsize);
- }
-
- return concatenated;
-}
-
/* Return prompt character of specified node. */
const char *
cmd_prompt (enum node_type node)
@@ -720,6 +699,8 @@ cmd_complete_command (vector vline, struct vty *vty, int *status)
vector_free (comps);
comps = NULL;
}
+ else if (initial_comps)
+ vector_free (initial_comps);
// comps should always be null here
assert (!comps);
@@ -805,6 +786,8 @@ cmd_execute_command_real (vector vline,
// if matcher error, return corresponding CMD_ERR
if (MATCHER_ERROR(status))
{
+ if (argv_list)
+ list_delete (argv_list);
switch (status)
{
case MATCHER_INCOMPLETE:
diff --git a/lib/command.h b/lib/command.h
index 8986703708..04bba9e412 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -410,7 +410,6 @@ extern int argv_find (struct cmd_token **argv, int argc, const char *text, int *
extern vector cmd_make_strvec (const char *);
extern void cmd_free_strvec (vector);
-extern char *cmd_concat_strvec (vector);
extern vector cmd_describe_command (vector, struct vty *, int *status);
extern char **cmd_complete_command (vector, struct vty *, int *status);
extern const char *cmd_prompt (enum node_type);
diff --git a/lib/csv.c b/lib/csv.c
index 7df9292647..4fd14918fd 100644
--- a/lib/csv.c
+++ b/lib/csv.c
@@ -239,6 +239,9 @@ csv_encode (csv_t *csv,
rec = malloc(sizeof(csv_record_t));
if (!rec) {
log_error("record malloc failed\n");
+ if (!buf)
+ free(str);
+ va_end(list);
return (NULL);
}
csv_init_record(rec);
@@ -255,6 +258,7 @@ csv_encode (csv_t *csv,
if (!fld) {
log_error("fld malloc failed\n");
csv_remove_record(csv, rec);
+ va_end(list);
return (NULL);
}
if (tempc < (count - 1)) {
@@ -518,7 +522,7 @@ csv_concat_record (csv_t *csv,
curr = (char *)calloc(1, csv->buflen);
if (!curr) {
log_error("field str malloc failed\n");
- return (NULL);
+ goto out_rec;
}
rec->record = curr;
@@ -526,7 +530,7 @@ csv_concat_record (csv_t *csv,
ret = strstr(rec1->record, "\n");
if (!ret) {
log_error("rec1 str not properly formatted\n");
- return (NULL);
+ goto out_curr;
}
snprintf(curr, (int)(ret - rec1->record + 1), "%s", rec1->record);
@@ -535,7 +539,7 @@ csv_concat_record (csv_t *csv,
ret = strstr(rec2->record, "\n");
if (!ret) {
log_error("rec2 str not properly formatted\n");
- return (NULL);
+ goto out_curr;
}
snprintf((curr+strlen(curr)), (int)(ret - rec2->record + 1), "%s",
@@ -556,6 +560,12 @@ csv_concat_record (csv_t *csv,
csv_insert_record(csv, rec);
return rec;
+
+out_curr:
+ free(curr);
+out_rec:
+ free(rec);
+ return NULL;
}
void
@@ -569,6 +579,8 @@ csv_decode (csv_t *csv, char *inbuf)
pos = strpbrk(buf, "\n");
while (pos != NULL) {
rec = calloc(1, sizeof(csv_record_t));
+ if (!rec)
+ return;
csv_init_record(rec);
TAILQ_INSERT_TAIL(&(csv->records), rec, next_record);
csv->num_recs++;
diff --git a/lib/plist.c b/lib/plist.c
index 41cae020de..4539d82972 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -557,10 +557,11 @@ prefix_list_entry_delete (struct prefix_list *plist,
struct prefix_list_entry *pentry,
int update_list)
{
- prefix_list_trie_del (plist, pentry);
-
if (plist == NULL || pentry == NULL)
return;
+
+ prefix_list_trie_del (plist, pentry);
+
if (pentry->prev)
pentry->prev->next = pentry->next;
else
diff --git a/lib/prefix.c b/lib/prefix.c
index 8289593781..bc1c681058 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -723,20 +723,6 @@ apply_mask_ipv6 (struct prefix_ipv6 *p)
}
void
-str2in6_addr (const char *str, struct in6_addr *addr)
-{
- int i;
- unsigned int x;
-
- /* %x must point to unsinged int */
- for (i = 0; i < 16; i++)
- {
- sscanf (str + (i * 2), "%02x", &x);
- addr->s6_addr[i] = x & 0xff;
- }
-}
-
-void
apply_mask (struct prefix *p)
{
switch (p->family)
diff --git a/lib/prefix.h b/lib/prefix.h
index 45e6368463..eb69e98f04 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -281,7 +281,6 @@ extern void apply_mask_ipv6 (struct prefix_ipv6 *);
extern int ip6_masklen (struct in6_addr);
extern void masklen2ip6 (const int, struct in6_addr *);
-extern void str2in6_addr (const char *, struct in6_addr *);
extern const char *inet6_ntoa (struct in6_addr);
static inline int ipv6_martian (struct in6_addr *addr)
diff --git a/lib/routemap.c b/lib/routemap.c
index 49b3039838..39d9a5d375 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -800,29 +800,29 @@ route_map_free_map (struct route_map *map)
struct route_map_list *list;
struct route_map_index *index;
+ if (map == NULL)
+ return;
+
while ((index = map->head) != NULL)
route_map_index_delete (index, 0);
list = &route_map_master;
- if (map != NULL)
- {
- QOBJ_UNREG (map);
+ QOBJ_UNREG (map);
- if (map->next)
- map->next->prev = map->prev;
- else
- list->tail = map->prev;
+ if (map->next)
+ map->next->prev = map->prev;
+ else
+ list->tail = map->prev;
- if (map->prev)
- map->prev->next = map->next;
- else
- list->head = map->next;
+ if (map->prev)
+ map->prev->next = map->next;
+ else
+ list->head = map->next;
- hash_release(route_map_master_hash, map);
- XFREE (MTYPE_ROUTE_MAP_NAME, map->name);
- XFREE (MTYPE_ROUTE_MAP, map);
- }
+ hash_release(route_map_master_hash, map);
+ XFREE (MTYPE_ROUTE_MAP_NAME, map->name);
+ XFREE (MTYPE_ROUTE_MAP, map);
}
/* Route map delete from list. */
@@ -1053,7 +1053,7 @@ vty_show_route_map (struct vty *vty, const char *name)
{
if (zlog_default)
vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
- if (zlog_default->instance)
+ if (zlog_default && zlog_default->instance)
vty_out (vty, " %d", zlog_default->instance);
vty_out (vty, ": 'route-map %s' not found%s", name, VTY_NEWLINE);
return CMD_SUCCESS;