microsoft / FFmpegInterop

This is a code sample to make it easier to use FFmpeg in Windows applications.
Apache License 2.0
1.29k stars 310 forks source link

MSFT: 49847737 - FFmpegInteropBuffer is leaking its underlying buffer #309

Closed brbeec closed 5 months ago

brbeec commented 5 months ago

Why is this change being made?

There is a memory leak due to FFmpegInteropBuffer not properly capturing the smart pointer for its underlying buffer in the unique_ptr deleter lambdas, which causes the underlying buffer to not be deallocated when FFmpegInteropBuffer is destroyed.

What changed?

Updated FFmpegInteropBuffer to properly move capture the smart pointer for its underlying buffer in the unique_ptr deleter lambdas, so that the underlying buffer is deallocated when FFmpegInteropBuffer is destroyed.

How was the change tested?

I verified under a debugger that the underlying buffer is now being deallocated when FFmpegInteropBuffer is destroyed and memory usage is stable for Ogg playback in Media Player with in-proc WME.