From a273eb6413893791f9edf20b790684b25baf863c Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 16 Jul 2024 09:53:16 +0000 Subject: [PATCH] Fix crash on attempt to play audio from video without such stream --- client/media/CVideoHandler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/media/CVideoHandler.cpp b/client/media/CVideoHandler.cpp index e8537cf14..f2d929f02 100644 --- a/client/media/CVideoHandler.cpp +++ b/client/media/CVideoHandler.cpp @@ -494,7 +494,11 @@ std::pair, si64> CAudioInstance::extractAudio(const Vide if (!openInput(videoToOpen)) return { nullptr, 0}; openContext(); - openCodec(findAudioStream()); + + int audioStreamIndex = findAudioStream(); + if (audioStreamIndex == -1) + return { nullptr, 0}; + openCodec(audioStreamIndex); const auto * codecpar = getCodecParameters();