diff mbox

[FFmpeg-devel] ffplay: Don't crash if stream_cycle_channel() is called before initialization

Message ID CAB0OVGqZzu47mmp8RGQDgXC0Su4q0=X87enW3eP1E_PuNPBaDQ@mail.gmail.com
State Superseded
Headers show

Commit Message

Carl Eugen Hoyos June 10, 2018, 11:48 p.m. UTC
Hi!

Attached patch fixes a crash if SDL sends a keydown event before
stream and window initialization is finished, ticket #7252.

Please comment, Carl Eugen
diff mbox

Patch

From 43324194a81f1f33150fefac6336285ab95eb14f Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Mon, 11 Jun 2018 01:44:24 +0200
Subject: [PATCH] ffplay: Don't crash if stream_cycle_channel() is called
 before initialization.

SDL may send a keydown event before stream (and window) initialization is finished.

Fixes ticket #7252.
---
 fftools/ffplay.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 84ba667..5ace5cd 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3106,7 +3106,11 @@  static void stream_cycle_channel(VideoState *is, int codec_type)
     int old_index;
     AVStream *st;
     AVProgram *p = NULL;
-    int nb_streams = is->ic->nb_streams;
+    int nb_streams;
+
+    if (!is->ic)
+        return;
+    nb_streams = is->ic->nb_streams;
 
     if (codec_type == AVMEDIA_TYPE_VIDEO) {
         start_index = is->last_video_stream;
-- 
1.7.10.4