Browse code

dmq_usrloc: safety checks for sock field

- GH #3243

(cherry picked from commit 518296523db0c1735c3234d77d6af312f5c9babb)

Daniel-Constantin Mierla authored on 18/09/2022 18:09:53
Showing 1 changed files
... ...
@@ -681,7 +681,7 @@ int usrloc_dmq_send_multi_contact(ucontact_t* ptr, str aor, int action, dmq_node
681 681
 	jdoc_contact_group.size += ptr->c.len;
682 682
 	srjson_AddStrToObject(jdoc, jdoc_contact, "received", ptr->received.s, ptr->received.len);
683 683
 	jdoc_contact_group.size += ptr->received.len;
684
-	if (_dmq_usrloc_replicate_socket_info==1) {
684
+	if (_dmq_usrloc_replicate_socket_info==1 && ptr->sock!=NULL && ptr->sock->sock_str.s!=NULL) {
685 685
 		srjson_AddStrToObject(jdoc, jdoc_contact, "sock", ptr->sock->sock_str.s, ptr->sock->sock_str.len);
686 686
 		jdoc_contact_group.size += ptr->sock->sock_str.len;
687 687
 	}
... ...
@@ -709,8 +709,8 @@ int usrloc_dmq_send_multi_contact(ucontact_t* ptr, str aor, int action, dmq_node
709 709
 	jdoc_contact_group.size += snprintf(NULL,0,"%u", ptr->methods);
710 710
 	srjson_AddNumberToObject(jdoc, jdoc_contact, "reg_id", ptr->reg_id);
711 711
 	jdoc_contact_group.size += snprintf(NULL,0,"%d", ptr->reg_id);
712
-        srjson_AddNumberToObject(jdoc, jdoc_contact, "server_id", ptr->server_id);
713
-        jdoc_contact_group.size += snprintf(NULL,0,"%d", ptr->server_id);
712
+	srjson_AddNumberToObject(jdoc, jdoc_contact, "server_id", ptr->server_id);
713
+	jdoc_contact_group.size += snprintf(NULL,0,"%d", ptr->server_id);
714 714
 
715 715
 	char idx[5];
716 716
 	jdoc_contact_group.count++;