From 3b285cc7602d96f0228d8c76a5442c96b9cd8de8 Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Sun, 5 Mar 2006 21:34:23 +0000 Subject: [PATCH] sys/xvimage/xvimagesink.c: Check that the xvimage we are creating has a correct size before returning it. (#3... Original commit message from CVS: 2006-03-05 Julien MOUTTE * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xvimage_new), (gst_xvimagesink_show_frame), (gst_xvimagesink_buffer_alloc): Check that the xvimage we are creating has a correct size before returning it. (#314897) --- ChangeLog | 7 +++++++ sys/xvimage/xvimagesink.c | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb6fcb548e..88190f46c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-05 Julien MOUTTE + + * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xvimage_new), + (gst_xvimagesink_show_frame), (gst_xvimagesink_buffer_alloc): + Check that the xvimage we are creating has a correct size + before returning it. (#314897) + 2006-03-05 Tim-Philipp Müller * gst/typefind/gsttypefindfunctions.c: (plugin_init): diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index e160b1180f..5b172d4d87 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -473,7 +473,6 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps) g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL); - xvimage = (GstXvImageBuffer *) gst_mini_object_new (GST_TYPE_XVIMAGE_BUFFER); structure = gst_caps_get_structure (caps, 0); @@ -1834,7 +1833,8 @@ gst_xvimagesink_show_frame (GstBaseSink * bsink, GstBuffer * buf) xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink, GST_BUFFER_CAPS (buf)); - if (!xvimagesink->xvimage) + if ((!xvimagesink->xvimage) || + (xvimagesink->xvimage->size < GST_BUFFER_SIZE (buf))) goto no_image; } @@ -1976,6 +1976,11 @@ gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, /* We found no suitable image in the pool. Creating... */ GST_DEBUG_OBJECT (xvimagesink, "no usable image in pool, creating xvimage"); xvimage = gst_xvimagesink_xvimage_new (xvimagesink, intersection); + if (xvimage->size < size) { + /* This image is unusable. Destroying... */ + gst_xvimage_buffer_free (xvimage); + xvimage = NULL; + } } if (xvimage) {