[Asterisk-code-review] res pjsip: Fix initialization of extended stringfields. (asterisk[15])

Joshua Colp asteriskteam at digium.com
Wed Apr 25 04:28:48 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/8824 )

Change subject: res_pjsip: Fix initialization of extended stringfields.
......................................................................

res_pjsip: Fix initialization of extended stringfields.

It is possible for initialization of extended stringfields to fail.  Add
checks for this failure.

Change-Id: I062e09852db3d37ceefaf6c2048958fa0118304f
---
M res/res_pjsip/location.c
M res/res_pjsip/pjsip_configuration.c
2 files changed, 7 insertions(+), 9 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 2ce4a18..55c32ca 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -128,15 +128,14 @@
 		return NULL;
 	}
 
-	if (ast_string_field_init(contact, 256)) {
+	if (ast_string_field_init(contact, 256)
+		|| ast_string_field_init_extended(contact, endpoint_name)
+		|| ast_string_field_init_extended(contact, reg_server)
+		|| ast_string_field_init_extended(contact, via_addr)
+		|| ast_string_field_init_extended(contact, call_id)) {
 		ao2_cleanup(contact);
 		return NULL;
 	}
-
-	ast_string_field_init_extended(contact, endpoint_name);
-	ast_string_field_init_extended(contact, reg_server);
-	ast_string_field_init_extended(contact, via_addr);
-	ast_string_field_init_extended(contact, call_id);
 
 	/* Dynamic contacts are delimited with ";@" and static ones with "@@" */
 	if ((aor_separator = strstr(id, ";@")) || (aor_separator = strstr(id, "@@"))) {
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 3094f24..3efd0f4 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -2243,12 +2243,11 @@
 	if (!endpoint) {
 		return NULL;
 	}
-	if (ast_string_field_init(endpoint, 64)) {
+	if (ast_string_field_init(endpoint, 64)
+		|| ast_string_field_init_extended(endpoint, incoming_mwi_mailbox)) {
 		ao2_cleanup(endpoint);
 		return NULL;
 	}
-
-	ast_string_field_init_extended(endpoint, incoming_mwi_mailbox);
 
 	if (!(endpoint->media.codecs = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		ao2_cleanup(endpoint);

-- 
To view, visit https://gerrit.asterisk.org/8824
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I062e09852db3d37ceefaf6c2048958fa0118304f
Gerrit-Change-Number: 8824
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180425/e9421707/attachment-0001.html>


More information about the asterisk-code-review mailing list