From: Scott Griepentrog Date: Wed, 2 Mar 2016 17:17:54 +0000 (-0600) Subject: CHAOS: cleanup possible null vars on msg alloc failure X-Git-Tag: 14.0.0-beta1~369^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a3f0e85ace6f55fa5826c301ccaac066d24a11f;p=thirdparty%2Fasterisk.git CHAOS: cleanup possible null vars on msg alloc failure In message.c, if msg_alloc fails to init the string field, vars may be null, so use a null tolerant cleanup. In res_pjsip_messaging.c, if msg_data_create fails, mdata will be null, so use a null tolerant cleanup. ASTERISK-25323 Change-Id: Ic2d55c2c3750d5616e2a05ea92a19c717507ff56 --- diff --git a/main/message.c b/main/message.c index 7098f698d0..54c604c47d 100644 --- a/main/message.c +++ b/main/message.c @@ -398,7 +398,7 @@ static void msg_destructor(void *obj) struct ast_msg *msg = obj; ast_string_field_free_memory(msg); - ao2_ref(msg->vars, -1); + ao2_cleanup(msg->vars); } struct ast_msg *ast_msg_alloc(void) diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c index 7532e39be5..9a31630e71 100644 --- a/res/res_pjsip_messaging.c +++ b/res/res_pjsip_messaging.c @@ -597,7 +597,7 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f if (!(mdata = msg_data_create(msg, to, from)) || ast_sip_push_task(message_serializer, msg_send, mdata)) { - ao2_ref(mdata, -1); + ao2_cleanup(mdata); return -1; } return 0;