diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-10-05 16:51:01 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-10-05 16:53:13 +0200 |
commit | affe9e99831408960b8b6f8477506ed2874a05dd (patch) | |
tree | a6f2f7a898fad5fcdc3f74b233095b6e8f6a2b46 /lib/linklist.h | |
parent | Merge pull request #1244 from donaldsharp/flush_routes (diff) | |
download | frr-affe9e99831408960b8b6f8477506ed2874a05dd.tar.xz frr-affe9e99831408960b8b6f8477506ed2874a05dd.zip |
*: 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 <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/linklist.h')
-rw-r--r-- | lib/linklist.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/linklist.h b/lib/linklist.h index 9bd6e3849..5ae728ce0 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -74,7 +74,20 @@ extern void listnode_delete(struct list *, void *); extern struct listnode *listnode_lookup(struct list *, void *); extern void *listnode_head(struct list *); -extern void list_delete(struct list *); +/* + * The usage of list_delete is being transitioned to pass in + * the double pointer to remove use after free's. + * In Oct of 2018, rename list_delete_and_null to list_delete + * and remove list_delete_original and the list_delete #define + */ +#if CONFDATE > 20181001 +CPP_NOTICE("list_delete without double pointer is deprecated, please fixup") +#endif +extern void list_delete_and_null(struct list **); +extern void list_delete_original(struct list *); +#define list_delete(X) list_delete_original((X)) \ + CPP_WARN("Please transition to using list_delete_and_null") + extern void list_delete_all_node(struct list *); /* For ospfd and ospf6d. */ |