summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorScott Griepentrog <scott@griepentrog.com>2016-03-02 09:34:10 -0600
committerScott Griepentrog <sgriepentrog@digium.com>2016-03-02 11:59:33 -0600
commit3c37c7071f82eca8cc068fee6c16a842eddbddb6 (patch)
tree8c95487dbe32d8e9f7b96bbe0bdd23cc9a23f992 /res
parentd1495bc0ebed86d322488bed647b43aba0ae9b1f (diff)
CHAOS: prevent crash on failed strdup
This patch avoids crashing on a null pointer if the strdup() allocation fails. ASTERISK-25323 Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5
Diffstat (limited to 'res')
-rw-r--r--res/res_pjsip_messaging.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 54880dba9..fe285d8a4 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -530,6 +530,10 @@ static struct msg_data* msg_data_create(const struct ast_msg *msg, const char *t
/* Make sure we start with sip: */
mdata->to = ast_begins_with(to, "sip:") ? ast_strdup(++to) : ast_strdup(to - 3);
mdata->from = ast_strdup(from);
+ if (!mdata->to || !mdata->from) {
+ ao2_ref(mdata, -1);
+ return NULL;
+ }
/* sometimes from can still contain the tag at this point, so remove it */
if ((tag = strchr(mdata->from, ';'))) {