Jelajahi Sumber

Fix crash on attempt to play audio from video without such stream

Ivan Savenko 1 tahun lalu
induk
melakukan
a273eb6413
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  1. 5 1
      client/media/CVideoHandler.cpp

+ 5 - 1
client/media/CVideoHandler.cpp

@@ -494,7 +494,11 @@ std::pair<std::unique_ptr<ui8 []>, 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();