Commit 1ca7de02 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MediaPlayer: getTracksDescription: Ensure the track list always gets released

An exception might be thrown by emplace_back
parent 48e272a7
......@@ -1634,16 +1634,17 @@ public:
private:
std::vector<TrackDescription> getTracksDescription( libvlc_track_description_t* tracks ) const
{
if ( tracks == nullptr )
return {};
std::vector<TrackDescription> result;
if ( tracks == NULL )
return result;
libvlc_track_description_t* p = tracks;
while ( p != NULL )
auto p = tracks;
std::unique_ptr<libvlc_track_description_t, decltype(&libvlc_track_description_list_release)>
devicePtr( tracks, libvlc_track_description_list_release );
while ( p != nullptr )
{
result.emplace_back( p );
p = p->p_next;
}
libvlc_track_description_list_release(tracks);
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment