From 66ea6dd5f9ebba70c70612d88e1cece76b697f92 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Wed, 18 Apr 2018 17:24:31 -0400 Subject: [PATCH] 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 --- res/res_pjsip/location.c | 11 +++++------ res/res_pjsip/pjsip_configuration.c | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c index 2ce4a18696..55c32cacc0 100644 --- a/res/res_pjsip/location.c +++ b/res/res_pjsip/location.c @@ -128,16 +128,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'; diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index 3094f248eb..3efd0f4470 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -2243,13 +2243,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; -- 2.47.2