Selaa lähdekoodia

modules_k/dialog: Fix a bug that would cause a segfault when
caller bind address information could not be retrieved from
database and "dlg_list" was fifo-issued.

- Check nulliness of dlg->bind_addr[DLG_CALLER_LEG] before
printing.
(May be NULL when server doesn't feel responsible for a bound
address loaded from dialog database.)
- Move check-and-print code for both directions (caller and
callee) next to each other.

Timo Reimann 14 vuotta sitten
vanhempi
commit
ab21b25652
1 muutettua tiedostoa jossa 18 lisäystä ja 13 poistoa
  1. 18 13
      modules_k/dialog/dlg_hash.c

+ 18 - 13
modules_k/dialog/dlg_hash.c

@@ -884,11 +884,25 @@ static inline int internal_mi_print_dlg(struct mi_node *rpl,
 	if(node1 == 0)
 		goto error;
 
-	node1 = add_mi_node_child(node, 0,"caller_bind_addr",16,
-			dlg->bind_addr[DLG_CALLER_LEG]->sock_str.s, 
+	if (dlg->bind_addr[DLG_CALLER_LEG]) {
+		node1 = add_mi_node_child(node, 0,
+			"caller_bind_addr",16,
+			dlg->bind_addr[DLG_CALLER_LEG]->sock_str.s,
 			dlg->bind_addr[DLG_CALLER_LEG]->sock_str.len);
-	if(node1 == 0)
-		goto error;
+	} else {
+		node1 = add_mi_node_child(node, 0,
+			"caller_bind_addr",16,0,0);
+	}
+
+	if (dlg->bind_addr[DLG_CALLEE_LEG]) {
+		node1 = add_mi_node_child(node, 0,
+			"callee_bind_addr",16,
+			dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.s,
+			dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.len);
+	} else {
+		node1 = add_mi_node_child(node, 0,
+			"callee_bind_addr",16,0,0);
+	}
 
 	node1 = add_mi_node_child(node, MI_DUP_VALUE, "to_uri", 6,
 			dlg->to_uri.s, dlg->to_uri.len);
@@ -918,15 +932,6 @@ static inline int internal_mi_print_dlg(struct mi_node *rpl,
 	if(node1 == 0)
 		goto error;
 
-	if (dlg->bind_addr[DLG_CALLEE_LEG]) {
-		node1 = add_mi_node_child(node, 0,
-			"callee_bind_addr",16,
-			dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.s, 
-			dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.len);
-	} else {
-		node1 = add_mi_node_child(node, 0,
-			"callee_bind_addr",16,0,0);
-	}
 	if(node1 == 0)
 		goto error;