diff options
author | Scott Griepentrog <scott@griepentrog.com> | 2016-03-02 09:34:10 -0600 |
---|---|---|
committer | Scott Griepentrog <scott@griepentrog.com> | 2016-03-02 10:29:16 -0600 |
commit | 60aa871be3a9a5de2d5029a19b7f8fcfb7f4ea88 (patch) | |
tree | 39c3ad8ecd1b7cfc3777059ab6785e1acc92256d | |
parent | d0b26c3133e831e915990fd806257d9ef07c508b (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
-rw-r--r-- | res/res_pjsip_messaging.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c index 7532e39be..20d1f9d99 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, ';'))) { |