Skip to content

Commit 46c323a

Browse files
authored
Merge pull request #27 from qlyoung/fix-derefs2
bgpd, lib: fix a few scan-build catches
2 parents 15667da + c01d03a commit 46c323a

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

bgpd/bgp_route.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9521,7 +9521,7 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
95219521
char *vrf = NULL;
95229522
char *rmap_name = NULL;
95239523
char *peerstr = NULL;
9524-
int rcvd;
9524+
int rcvd = 0;
95259525

95269526
struct peer *peer;
95279527

lib/command.c

+3
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ cmd_concat_strvec (vector v)
299299
if (vector_slot (v, i))
300300
strsize += strlen ((char *) vector_slot (v, i)) + 1;
301301

302+
if (strsize == 0)
303+
return XSTRDUP (MTYPE_TMP, "");
304+
302305
char *concatenated = calloc (sizeof (char), strsize);
303306
for (unsigned int i = 0; i < vector_active (v); i++)
304307
{

lib/command_match.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ add_nexthops (struct list *list, struct graph_node *node,
482482
child = vector_slot (node->to, i);
483483
size_t j;
484484
struct cmd_token *token = child->data;
485-
if (!token->allowrepeat)
485+
if (!token->allowrepeat && stack)
486486
{
487487
for (j = 0; j < stackpos; j++)
488488
if (child == stack[j])

lib/routemap.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,11 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
989989

990990
/* Print the name of the protocol */
991991
if (zlog_default)
992+
{
992993
vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
993-
if (zlog_default->instance)
994-
vty_out (vty, " %d", zlog_default->instance);
994+
if (zlog_default->instance)
995+
vty_out (vty, " %d", zlog_default->instance);
996+
}
995997
vty_out (vty, ":%s", VTY_NEWLINE);
996998

997999
for (index = map->head; index; index = index->next)
@@ -2766,17 +2768,16 @@ DEFUN (rmap_call,
27662768
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
27672769
const char *rmap = argv[idx_word]->arg;
27682770

2769-
if (index)
2771+
assert(index);
2772+
2773+
if (index->nextrm)
27702774
{
2771-
if (index->nextrm)
2772-
{
2773-
route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
2774-
index->nextrm,
2775-
index->map->name);
2776-
XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
2777-
}
2778-
index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
2775+
route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
2776+
index->nextrm,
2777+
index->map->name);
2778+
XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
27792779
}
2780+
index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
27802781

27812782
/* Execute event hook. */
27822783
route_map_upd8_dependency (RMAP_EVENT_CALL_ADDED,

0 commit comments

Comments
 (0)