]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
CHAOS: cleanup possible null vars on msg alloc failure 44/2344/2
authorScott Griepentrog <scott@griepentrog.com>
Wed, 2 Mar 2016 17:17:54 +0000 (11:17 -0600)
committerScott Griepentrog <sgriepentrog@digium.com>
Wed, 2 Mar 2016 18:00:37 +0000 (12:00 -0600)
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

main/message.c
res/res_pjsip_messaging.c

index 01a1c9b1cd5f72344e5068621f148cc3abd90322..c15975b63156ae726b20b96bdcccd742fcdcb8c3 100644 (file)
@@ -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)
index 54880dba92ad5ed3760819eb5c65af138e7fe6f5..f7d2e0a674501a960aa1e2610811c7739c5ceece 100644 (file)
@@ -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;