ximagesink: Check if the X context is allocated before using it
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 10 May 2010 10:44:41 +0000 (12:44 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 10 May 2010 10:44:41 +0000 (12:44 +0200)
It should be allocated at these places already or the state changes
would have failed... but better add an additional check here.

sys/ximage/ximagesink.c

index 713615c..f8bcf57 100644 (file)
@@ -1658,6 +1658,11 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
 
   ximagesink = GST_XIMAGESINK (vsink);
 
+  /* This shouldn't really happen because state changes will fail
+   * if the xcontext can't be allocated */
+  if (!ximagesink->xcontext)
+    return GST_FLOW_ERROR;
+
   /* If this buffer has been allocated using our buffer management we simply
      put the ximage which is in the PRIVATE pointer */
   if (GST_IS_XIMAGE_BUFFER (buf)) {
@@ -1768,6 +1773,11 @@ gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
 
   ximagesink = GST_XIMAGESINK (bsink);
 
+  /* This shouldn't really happen because state changes will fail
+   * if the xcontext can't be allocated */
+  if (!ximagesink->xcontext)
+    return GST_FLOW_ERROR;
+
   GST_LOG_OBJECT (ximagesink,
       "a buffer of %d bytes was requested with caps %" GST_PTR_FORMAT
       " and offset %" G_GUINT64_FORMAT, size, caps, offset);