From 3c39d2af9aaeb10e83fa580409c3b20f3750d85f Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Mon, 17 Feb 2020 17:05:06 +0100 Subject: [PATCH] streaminfo2: fix segfault with unknown media_type Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/c60990407b396277453564ef07ad6432cd12c673 Author: Jacek Jendrzej Date: 2020-02-17 (Mon, 17 Feb 2020) --- src/gui/streaminfo2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 352ef8f33..6b84af08c 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -183,11 +183,13 @@ void CStreamInfo2::analyzeStream(AVFormatContext *avfc, unsigned int idx) size_t pos = m["codec"].find_first_of(":"); if (pos != std::string::npos) m["codec"] = m["codec"].erase(0, pos + 2); + #if (LIBAVFORMAT_VERSION_MAJOR > 57) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR > 32)) - m["codec_type"] = av_get_media_type_string(st->codecpar->codec_type); + std::string codecType = av_get_media_type_string(st->codecpar->codec_type) ? av_get_media_type_string(st->codecpar->codec_type):"unknown"; #else - m["codec_type"] = av_get_media_type_string(st->codec->codec_type); + std::string codecType = av_get_media_type_string(st->codec->codec_type) ? av_get_media_type_string(st->codec->codec_type):"unknown"; #endif + m["codec_type"] = codecType; m["codec_type"][0] ^= 'a' ^ 'A'; m["pid"] = to_string(st->id);