aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorAntonio Ospite <ospite@studenti.unina.it>2012-03-16 22:23:34 +0100
committerRonald S. Bultje <rsbultje@gmail.com>2012-03-16 15:39:33 -0700
commitd3958ab4edf49cb760412d8687c870d349f692c7 (patch)
tree93fa3b217aab31c5b167d5072f2dda2aede246be /libavdevice
parent05b9a89ed71846be266f283b9d188e0fcb2f0323 (diff)
downloadffmpeg-d3958ab4edf49cb760412d8687c870d349f692c7.tar.gz
x11grab: fix a memory leak exposed by valgrind
When using "-f x11grab -i :0.0" valgrind reports a definitely lost memory block with this message: ==31544== 5 bytes in 1 blocks are definitely lost in loss record 1 of 2 ==31544== at 0x4026E68: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==31544== by 0x4026F17: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==31544== by 0x60D399A: av_malloc (in /usr/lib/x86_64-linux-gnu/libavutil.so.51.22.1) ==31544== by 0x60D3A70: av_strdup (in /usr/lib/x86_64-linux-gnu/libavutil.so.51.22.1) ==31544== by 0x4A2BE58: ??? (in /usr/lib/x86_64-linux-gnu/libavdevice.so.53.2.0) ==31544== by 0x506D29E: avformat_open_input (in /usr/lib/x86_64-linux-gnu/libavformat.so.53.21.0) ==31544== by 0x400A80: main (in /home/ao2/WIP/am7xxx-play/tests/a.out) The 5 bytes lost are the ones from param = av_strdup(":0.0"), so let's free param in the exit path. Also check the av_strdup() return value. Note: calling av_free(param) even when av_strdup() fails and param is NULL is OK and keeps the code simpler without adding another label to skip av_free(). Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/x11grab.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index 305fda6e76..06cec9daef 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -169,6 +169,9 @@ x11grab_read_header(AVFormatContext *s1)
AVRational framerate;
param = av_strdup(s1->filename);
+ if (!param)
+ goto out;
+
offset = strchr(param, '+');
if (offset) {
sscanf(offset, "%d,%d", &x_off, &y_off);
@@ -319,6 +322,7 @@ x11grab_read_header(AVFormatContext *s1)
st->codec->bit_rate = x11grab->frame_size * 1/av_q2d(x11grab->time_base) * 8;
out:
+ av_free(param);
return ret;
}