[Asterisk-code-review] CHAOS: prevent crash on failed strdup (asterisk[master])
Scott Griepentrog
asteriskteam at digium.com
Wed Mar 2 09:36:49 CST 2016
Scott Griepentrog has uploaded a new change for review.
https://gerrit.asterisk.org/2340
Change subject: CHAOS: prevent crash on failed strdup
......................................................................
CHAOS: prevent crash on failed strdup
This patch avoids crashing on a null pointer
if the strdup() allocation fails.
ASTERISK-25323
Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5
---
M res/res_pjsip_messaging.c
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/40/2340/1
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 7532e39..6303f7b 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -530,6 +530,10 @@
/* 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->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, ';'))) {
--
To view, visit https://gerrit.asterisk.org/2340
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Scott Griepentrog <sgriepentrog at digium.com>
More information about the asterisk-code-review
mailing list