summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-01-06 19:36:59 -0500
committerGitHub <noreply@github.com>2017-01-06 19:36:59 -0500
commit46c323a66bee2899292885085ec7e7b51be095c3 (patch)
tree6f3d20049b091876659150b806d68d392d5d0394
parent15667da96d34556edbb6050008fe3ae2f0f75f8e (diff)
parentc01d03a6587b18722e5a7381084591e01eca64b5 (diff)
Merge pull request #27 from qlyoung/fix-derefs2
bgpd, lib: fix a few scan-build catches
-rw-r--r--bgpd/bgp_route.c2
-rw-r--r--lib/command.c3
-rw-r--r--lib/command_match.c2
-rw-r--r--lib/routemap.c23
4 files changed, 17 insertions, 13 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index e40c1fe25b..1215fe0f5b 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -9521,7 +9521,7 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
char *vrf = NULL;
char *rmap_name = NULL;
char *peerstr = NULL;
- int rcvd;
+ int rcvd = 0;
struct peer *peer;
diff --git a/lib/command.c b/lib/command.c
index 35aac3e6e3..6294e994e7 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -299,6 +299,9 @@ cmd_concat_strvec (vector v)
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++)
{
diff --git a/lib/command_match.c b/lib/command_match.c
index 62905a4f7f..d228563240 100644
--- a/lib/command_match.c
+++ b/lib/command_match.c
@@ -482,7 +482,7 @@ add_nexthops (struct list *list, struct graph_node *node,
child = vector_slot (node->to, i);
size_t j;
struct cmd_token *token = child->data;
- if (!token->allowrepeat)
+ if (!token->allowrepeat && stack)
{
for (j = 0; j < stackpos; j++)
if (child == stack[j])
diff --git a/lib/routemap.c b/lib/routemap.c
index 487790bbfb..74bae1fd76 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -989,9 +989,11 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
/* Print the name of the protocol */
if (zlog_default)
+ {
vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
- if (zlog_default->instance)
- vty_out (vty, " %d", zlog_default->instance);
+ if (zlog_default->instance)
+ vty_out (vty, " %d", zlog_default->instance);
+ }
vty_out (vty, ":%s", VTY_NEWLINE);
for (index = map->head; index; index = index->next)
@@ -2766,17 +2768,16 @@ DEFUN (rmap_call,
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
const char *rmap = argv[idx_word]->arg;
- if (index)
+ assert(index);
+
+ if (index->nextrm)
{
- if (index->nextrm)
- {
- route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
- index->nextrm,
- index->map->name);
- XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
- }
- index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
+ route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
+ index->nextrm,
+ index->map->name);
+ XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
}
+ index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
/* Execute event hook. */
route_map_upd8_dependency (RMAP_EVENT_CALL_ADDED,