txtinfo: avoid a potential null deref in 2-hop
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sat, 20 Feb 2016 10:54:56 +0000 (11:54 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 21 Feb 2016 12:23:40 +0000 (13:23 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/txtinfo/src/olsrd_txtinfo.c

index e13eca8..3bdcb07 100644 (file)
@@ -164,7 +164,9 @@ static void ipc_print_neighbors_internal(struct autobuf *abuf, bool list_2hop) {
 
     for (list_2 = neigh->neighbor_2_list.next; list_2 != &neigh->neighbor_2_list; list_2 = list_2->next) {
       if (list_2hop) {
-        abuf_appendf(abuf, "\t%s", olsr_ip_to_string(&neighAddrBuf, &list_2->neighbor_2->neighbor_2_addr));
+        if (list_2->neighbor_2) {
+          abuf_appendf(abuf, "\t%s", olsr_ip_to_string(&neighAddrBuf, &list_2->neighbor_2->neighbor_2_addr));
+        }
       } else {
         thop_cnt++;
       }