]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
rtp_engine: improved handling of get_rtp_info failure
authorScott Griepentrog <sgriepentrog@digium.com>
Tue, 28 Jan 2014 16:36:46 +0000 (16:36 +0000)
committerScott Griepentrog <sgriepentrog@digium.com>
Tue, 28 Jan 2014 16:36:46 +0000 (16:36 +0000)
In ast_rtp_instance_make_compatible(), after a failure of
channel tech call get_rtp_info() to return peer_instance,
the null pointer would be passed to ao2_ref, producing an
error that looked like a refernce counting problem but is
not.  This patch corrects that and adds helpful LOG_ERROR
messages to indicate which failure path occurred.

(issue AST-1276)
Review: https://reviewboard.asterisk.org/r/3156/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@406721 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/rtp_engine.c

index 0f9c84e011f5ae1667570dacd498be54c360fd23..3b0a7dfb7ea7b68e4bdcc1daafb8d65370b3e995 100644 (file)
@@ -1697,11 +1697,15 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in
        }
 
        glue->get_rtp_info(peer, &peer_instance);
-
-       if (!peer_instance || peer_instance->engine != instance->engine) {
+       if (!peer_instance) {
+               ast_log(LOG_ERROR, "Unable to get_rtp_info for peer type %s\n", glue->type);
+               ast_channel_unlock(peer);
+               return -1;
+       }
+       if (peer_instance->engine != instance->engine) {
+               ast_log(LOG_ERROR, "Peer engine mismatch for type %s\n", glue->type);
                ast_channel_unlock(peer);
                ao2_ref(peer_instance, -1);
-               peer_instance = NULL;
                return -1;
        }