summaryrefslogtreecommitdiffstats
path: root/libavfilter/defaults.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-08-17 15:12:28 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-08-17 15:12:28 +0000
commit65d4cab5627f9c8add3eff73f0d1148a8a95e91c (patch)
treefeba6888f4b0cb04cfe462b8b03c628fe68c10aa /libavfilter/defaults.c
parent4f9ce3c4c796d475656161644cca9bead523d6e7 (diff)
downloadffmpeg-streaming-65d4cab5627f9c8add3eff73f0d1148a8a95e91c.zip
ffmpeg-streaming-65d4cab5627f9c8add3eff73f0d1148a8a95e91c.tar.gz
Add missing checks in avfilter_default_get_video_buffer().
Originally committed as revision 24809 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/defaults.c')
-rw-r--r--libavfilter/defaults.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index e275982..57d343f 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -35,9 +35,12 @@ static void avfilter_default_free_buffer(AVFilterBuffer *ptr)
AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{
AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
- AVFilterBufferRef *ref = av_mallocz(sizeof(AVFilterBufferRef));
+ AVFilterBufferRef *ref = NULL;
int i, tempsize;
- char *buf;
+ char *buf = NULL;
+
+ if (!pic || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))
+ goto fail;
ref->buf = pic;
ref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps));
@@ -58,12 +61,22 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
tempsize = av_fill_image_pointers(pic->data, ref->format, ref->video->h, NULL, pic->linesize);
buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be
// SIMD-friendly
+ if (!buf)
+ goto fail;
av_fill_image_pointers(pic->data, ref->format, ref->video->h, buf, pic->linesize);
memcpy(ref->data, pic->data, sizeof(ref->data));
memcpy(ref->linesize, pic->linesize, sizeof(ref->linesize));
return ref;
+
+fail:
+ av_free(buf);
+ if (ref && ref->video)
+ av_free(ref->video);
+ av_free(ref);
+ av_free(pic);
+ return NULL;
}
void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
OpenPOWER on IntegriCloud