]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Fix initialization of extended stringfields.
authorCorey Farrell <git@cfware.com>
Wed, 18 Apr 2018 21:24:31 +0000 (17:24 -0400)
committerCorey Farrell <git@cfware.com>
Wed, 18 Apr 2018 21:25:35 +0000 (15:25 -0600)
It is possible for initialization of extended stringfields to fail.  Add
checks for this failure.

Change-Id: I062e09852db3d37ceefaf6c2048958fa0118304f

res/res_pjsip/location.c
res/res_pjsip/pjsip_configuration.c

index 52d84c3ceb6617e79e2c414e175d0a557ce44384..3abba3bb4460fa90d47969c71ece86f5d3b4b47b 100644 (file)
@@ -118,16 +118,15 @@ static void *contact_alloc(const char *name)
                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, "@@"))) {
                *aor_separator = '\0';
index e88f019642e12fc79354772fcc8c884f9a9636b6..5e5d40c69133f8590cc4df21e4ac0799d430ca38 100644 (file)
@@ -2197,13 +2197,12 @@ void *ast_sip_endpoint_alloc(const char *name)
        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);
                return NULL;