From c1c3e4af5bbf09467acd6d25390b1c43d10f2240 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 14 Aug 2016 21:57:23 +0300 Subject: [PATCH] Stop reading audio input packets if AVERROR_INVALIDDATA is received. There are some audio files that cause swr_convert to crash otherwise. --- Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp | 8 +++++--- Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp index a8a4227f13..65fd1118a4 100644 --- a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp +++ b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.cpp @@ -275,9 +275,11 @@ AudioPlayerLoader::ReadResult FFMpegLoader::readMore(QByteArray &result, int64 & char err[AV_ERROR_MAX_STRING_SIZE] = { 0 }; LOG(("Audio Error: Unable to avcodec_send_packet() file '%1', data size '%2', error %3, %4").arg(file.name()).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res))); - if (res == AVERROR_INVALIDDATA) { - return ReadResult::NotYet; // try to skip bad packet - } + // There is a sample voice message where skipping such packet + // results in a crash (read_access to nullptr) in swr_convert(). + //if (res == AVERROR_INVALIDDATA) { + // return ReadResult::NotYet; // try to skip bad packet + //} return ReadResult::Error; } } diff --git a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp index 8932fcde3b..b5b7e8194f 100644 --- a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp +++ b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.cpp @@ -149,9 +149,11 @@ AudioPlayerLoader::ReadResult ChildFFMpegLoader::readMore(QByteArray &result, in char err[AV_ERROR_MAX_STRING_SIZE] = { 0 }; LOG(("Audio Error: Unable to avcodec_send_packet() file '%1', data size '%2', error %3, %4").arg(file.name()).arg(data.size()).arg(res).arg(av_make_error_string(err, sizeof(err), res))); - if (res == AVERROR_INVALIDDATA) { - return ReadResult::NotYet; // try to skip bad packet - } + // There is a sample voice message where skipping such packet + // results in a crash (read_access to nullptr) in swr_convert(). + //if (res == AVERROR_INVALIDDATA) { + // return ReadResult::NotYet; // try to skip bad packet + //} return ReadResult::Error; } FFMpeg::freePacket(&packet);