From affe9e99831408960b8b6f8477506ed2874a05dd Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Oct 2017 10:51:01 -0400 Subject: *: Convert list_delete(struct list *) to ** to allow nulling Convert the list_delete(struct list *) function to use struct list **. This is to allow the list pointer to be nulled. I keep running into uses of this list_delete function where we forget to set the returned pointer to NULL and attempt to use it and then experience a crash, usually after the developer has long since left the building. Let's make the api explicit in it setting the list pointer to null. Cynical Prediction: This code will expose a attempt to use the NULL'ed list pointer in some obscure bit of code. Signed-off-by: Donald Sharp --- lib/command.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/command.c') diff --git a/lib/command.c b/lib/command.c index d1b0867372..97eba96c3a 100644 --- a/lib/command.c +++ b/lib/command.c @@ -686,7 +686,7 @@ static vector cmd_complete_command_real(vector vline, struct vty *vty, } vector comps = completions_to_vec(completions); - list_delete(completions); + list_delete_and_null(&completions); // set status code appropriately switch (vector_active(comps)) { @@ -1006,7 +1006,7 @@ static int cmd_execute_command_real(vector vline, enum filter_type filter, // if matcher error, return corresponding CMD_ERR if (MATCHER_ERROR(status)) { if (argv_list) - list_delete(argv_list); + list_delete_and_null(&argv_list); switch (status) { case MATCHER_INCOMPLETE: return CMD_ERR_INCOMPLETE; @@ -1035,7 +1035,7 @@ static int cmd_execute_command_real(vector vline, enum filter_type filter, ret = matched_element->func(matched_element, vty, argc, argv); // delete list and cmd_token's in it - list_delete(argv_list); + list_delete_and_null(&argv_list); XFREE(MTYPE_TMP, argv); return ret; @@ -2730,6 +2730,6 @@ void cmd_terminate() if (host.config) XFREE(MTYPE_HOST, host.config); - list_delete(varhandlers); + list_delete_and_null(&varhandlers); qobj_finish(); } -- cgit v1.2.3