[FFmpeg-devel] x11grab.c: minor clean up, added more documentation

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Apr 1 17:56:45 CEST 2011

Sven C. Dack <sven.c.dack <at> virginmedia.com> writes:

> >> +    av_free(x11grab->dpyname);
> >>      
> > So I guess my solution, to free param immediately after the call to
> > XOpenDisplay(), was wrong
> >    
> What are you talking about?

I had the following (inlined) patch in my local tree since I applied "Remove a
memory allocation and the associated memcpy.".

diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index 6a674ee..b8fcd1a 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -106,5 +106,6 @@

     dpy = XOpenDisplay(param);
+    av_free(param);
     if(!dpy) {
         av_log(s1, AV_LOG_ERROR, "Could not open X display.\n");
         return AVERROR(EIO);

I have no idea if it is correct, but it fixed the memleak for me (and does not
crash here).
Is it wrong?

Carl Eugen

More information about the ffmpeg-devel mailing list