[FFmpeg-devel] Possible memory leaks in dshow capture

James Almer jamrial at gmail.com
Tue Jan 1 23:22:42 EET 2019


On 1/1/2019 6:16 PM, Moritz Barsnick wrote:
> On Tue, Jan 01, 2019 at 17:58:42 -0300, James Almer wrote:
>> Does the attached (untested) patch fix these two for you?
> [...]
>> +    if (!this)
>> +        return
>> +    av_freep(&this->imemvtbl);
> 
> Do add a semicolon after "return" for good measure. ;)
> 
> Moritz

Huh, curious, gcc 8 (mingw-w64) compiled this just fine without the
semicolon.
I'm attached a fixed version anyway.
-------------- next part --------------
diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c
index 664246da92..c0f8ec065d 100644
--- a/libavdevice/dshow_pin.c
+++ b/libavdevice/dshow_pin.c
@@ -249,8 +249,16 @@ libAVPin_Setup(libAVPin *this, libAVFilter *filter)
 
     return 1;
 }
+
+static void
+libAVPin_Free(libAVPin *this)
+{
+    if (!this)
+        return;
+    av_freep(&this->imemvtbl);
+}
 DECLARE_CREATE(libAVPin, libAVPin_Setup(this, filter), libAVFilter *filter)
-DECLARE_DESTROY(libAVPin, nothing)
+DECLARE_DESTROY(libAVPin, libAVPin_Free)
 
 /*****************************************************************************
  * libAVMemInputPin


More information about the ffmpeg-devel mailing list