]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: linklist avoid access NULL->data
authorVincent JARDIN <vincent.jardin@6wind.com>
Mon, 9 Oct 2017 08:51:03 +0000 (10:51 +0200)
committerVincent JARDIN <vincent.jardin@6wind.com>
Mon, 9 Oct 2017 08:51:03 +0000 (10:51 +0200)
Let's assert(NULL) if the datastructure is not set.
The code assumes that the pointer is always non NULL. So, let's enforce
this semantic.

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
lib/linklist.h

index 4a65fead861d0ddffab80ef5f0d7708c6aa5b0bf..8a43fbe64b1f34b8ae06696d303f48b289aec808 100644 (file)
@@ -56,7 +56,8 @@ struct list {
 #define listtail(X) ((X) ? ((X)->tail) : NULL)
 #define listcount(X) ((X)->count)
 #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)
-#define listgetdata(X) (assert((X)->data != NULL), (X)->data)
+/* return X->data only if X and X->data are not NULL */
+#define listgetdata(X) (assert(X), assert((X)->data != NULL), (X)->data)
 
 /* Prototypes. */
 extern struct list *