diff --git a/src/audiosource.cpp b/src/audiosource.cpp index 19eaccd..4ac003f 100644 --- a/src/audiosource.cpp +++ b/src/audiosource.cpp @@ -77,8 +77,10 @@ void LWAudioDecoder::OpenFile(const std::filesystem::path &SourceFile, int Track for (const auto &Iter : LAVFOpts) av_dict_set(&Dict, Iter.first.c_str(), Iter.second.c_str(), 0); - if (avformat_open_input(&FormatContext, SourceFile.u8string().c_str(), nullptr, &Dict) != 0) + if (avformat_open_input(&FormatContext, SourceFile.u8string().c_str(), nullptr, &Dict) != 0) { + av_dict_free(&Dict); throw BestSourceException("Couldn't open '" + SourceFile.u8string() + "'"); + } av_dict_free(&Dict); diff --git a/src/tracklist.cpp b/src/tracklist.cpp index 6bc47a0..5c52a53 100644 --- a/src/tracklist.cpp +++ b/src/tracklist.cpp @@ -20,6 +20,7 @@ #include "tracklist.h" #include +#include extern "C" { #include @@ -31,8 +32,10 @@ void BestTrackList::OpenFile(const std::filesystem::path &SourceFile, const std: for (const auto &Iter : LAVFOpts) av_dict_set(&Dict, Iter.first.c_str(), Iter.second.c_str(), 0); - if (avformat_open_input(&FormatContext, SourceFile.u8string().c_str(), nullptr, &Dict) != 0) + if (avformat_open_input(&FormatContext, SourceFile.u8string().c_str(), nullptr, &Dict) != 0) { + av_dict_free(&Dict); throw BestSourceException("Couldn't open '" + SourceFile.u8string() + "'"); + } av_dict_free(&Dict); diff --git a/src/videosource.cpp b/src/videosource.cpp index b1b2d21..adea3f9 100644 --- a/src/videosource.cpp +++ b/src/videosource.cpp @@ -131,8 +131,10 @@ void LWVideoDecoder::OpenFile(const std::filesystem::path &SourceFile, const std for (const auto &Iter : LAVFOpts) av_dict_set(&Dict, Iter.first.c_str(), Iter.second.c_str(), 0); - if (avformat_open_input(&FormatContext, SourceFile.u8string().c_str(), nullptr, &Dict) != 0) + if (avformat_open_input(&FormatContext, SourceFile.u8string().c_str(), nullptr, &Dict) != 0) { + av_dict_free(&Dict); throw BestSourceException("Couldn't open '" + SourceFile.u8string() + "'"); + } av_dict_free(&Dict);