rtsp: Fix a crash with the RTSP muxer

Message ID 20160915112454.69288-1-martin@martin.st
State Committed
Commit df3795025337479a639cb3cd26c93a4e82ccd4db
Headers show

Commit Message

Martin Storsjö Sept. 15, 2016, 11:24 a.m.
This was introduced in bc2a32969e.

The whole block that the statement was added to is only
relevant when used as a demuxer, but the other statements
there have had other if statements guarding them. Make
sure to only run this whole block if being used as a
demuxer.

CC: libav-stable@libav.org
---
This is relevant for the 12 release branch.
---
 libavformat/rtsp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Luca Barbato Sept. 15, 2016, 1:06 p.m. | #1
On 15/09/16 13:24, Martin Storsjö wrote:
> This was introduced in bc2a32969e.
> 
> The whole block that the statement was added to is only
> relevant when used as a demuxer, but the other statements
> there have had other if statements guarding them. Make
> sure to only run this whole block if being used as a
> demuxer.
> 
> CC: libav-stable@libav.org
> ---
> This is relevant for the 12 release branch.
> ---
>  libavformat/rtsp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

OK.

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index b9416d2..84b912f 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -827,7 +827,8 @@  int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
 
     if (!rtsp_st->transport_priv) {
          return AVERROR(ENOMEM);
-    } else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP) {
+    } else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP &&
+               s->iformat) {
         RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
         rtpctx->ssrc = rtsp_st->ssrc;
         if (rtsp_st->dynamic_handler) {