Commit a41743de authored by Alexandre Janniaux's avatar Alexandre Janniaux Committed by Tristan Matthews
Browse files

medialibrary: Thumbnailer: fix double-free

The picture was referenced on the ThumbnailerCtx object, which release
it whenever one is not nullptr. However, after the changes in !3088,
commit 2ea2c7eb, the release policy for
the picture being exported has been fixed to ensure the picture is
consumed whatever the conversion case.

Ensure the picture won't be released twice by swapping it from the
ThumbnailerCtx object before exporting.

Fix #27749
parent b024c077
......@@ -83,8 +83,13 @@ bool Thumbnailer::generate( const medialibrary::IMedia&, const std::string& mrl,
if ( ctx.thumbnail == nullptr )
return false;
/* Both picture_Export and ThumbnailerCtx will release the thumbnail, so
* ensure that only picture_Export does. */
picture_t *thumbnail = nullptr;
std::swap(thumbnail, ctx.thumbnail);
block_t* block;
if ( picture_Export( VLC_OBJECT( m_ml ), &block, nullptr, ctx.thumbnail,
if ( picture_Export( VLC_OBJECT( m_ml ), &block, nullptr, thumbnail,
VLC_CODEC_JPEG, desiredWidth, desiredHeight, true ) != VLC_SUCCESS )
return false;
auto blockPtr = vlc::wrap_cptr( block, &block_Release );
......
Supports Markdown
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