Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few scan-build catches #26

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -9497,7 +9497,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;

Expand Down
6 changes: 5 additions & 1 deletion lib/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,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++)
{
Expand Down Expand Up @@ -2404,12 +2407,13 @@ cmd_init (int terminal)
struct cmd_token *
new_cmd_token (enum cmd_token_type type, u_char attr, char *text, char *desc)
{
struct cmd_token *token = XMALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token));
struct cmd_token *token = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token));
token->type = type;
token->attr = attr;
token->text = text;
token->desc = desc;
token->arg = NULL;
token->allowrepeat = false;

return token;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/command_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
23 changes: 12 additions & 11 deletions lib/routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down