]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip.c: Move NULL check to where it will do some good. 99/999/1
authorRichard Mudgett <rmudgett@digium.com>
Tue, 21 Jul 2015 20:41:29 +0000 (15:41 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 31 Jul 2015 01:26:06 +0000 (20:26 -0500)
v11 only fix.

Change-Id: I340512f86cfd3a6f7703971fa8acfffc7d47132b

channels/chan_sip.c

index 57430ac6456f8b8790029de15149c15134e2436a..58384af53637cca02ecb7594eca676ba14795e81 100644 (file)
@@ -12663,6 +12663,12 @@ static void add_codec_to_sdp(const struct sip_pvt *p,
        struct ast_format_list fmt;
        const char *mime;
        unsigned int rate;
+       struct ast_codec_pref *pref;
+
+       if (!p->rtp) {
+               /* I don't see how you couldn't have p->rtp, but good to check for and error out if not there like earlier code */
+               return;
+       }
 
        if (debug)
                ast_verbose("Adding codec %u (%s) to SDP\n", format->id, ast_getformatname(format));
@@ -12673,11 +12679,9 @@ static void add_codec_to_sdp(const struct sip_pvt *p,
                return;
        }
 
-       if (p->rtp) {
-               struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(p->rtp)->pref;
-               fmt = ast_codec_pref_getsize(pref, format);
-       } else /* I don't see how you couldn't have p->rtp, but good to check for and error out if not there like earlier code */
-               return;
+       pref = &ast_rtp_instance_get_codecs(p->rtp)->pref;
+       fmt = ast_codec_pref_getsize(pref, format);
+
        ast_str_append(m_buf, 0, " %d", rtp_code);
        ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u\r\n", rtp_code, mime, rate);