From 7ed27c264cb69f830cf79fe1634adf624f46b16d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Zanelli?= <aurelien.zanelli@parrot.com>
Date: Wed, 8 Oct 2014 10:35:14 +0200
Subject: [PATCH] v4l2bufferpool: check that allocator is non null when
 stopping pool

Otherwise, we could dereference NULL allocator when the stop method is
called by the GstBufferPool's finalize method.

https://bugzilla.gnome.org/show_bug.cgi?id=738102
---
 sys/v4l2/gstv4l2bufferpool.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
index 61e2faa549..90215e0ffe 100644
--- a/sys/v4l2/gstv4l2bufferpool.c
+++ b/sys/v4l2/gstv4l2bufferpool.c
@@ -799,7 +799,8 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
   if (!gst_v4l2_buffer_pool_streamoff (pool))
     goto streamoff_failed;
 
-  gst_v4l2_allocator_flush (pool->vallocator);
+  if (pool->vallocator)
+    gst_v4l2_allocator_flush (pool->vallocator);
 
   for (i = 0; i < VIDEO_MAX_FRAME; i++) {
     if (pool->buffers[i]) {
@@ -818,7 +819,7 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
 
   ret = GST_BUFFER_POOL_CLASS (parent_class)->stop (bpool);
 
-  if (ret) {
+  if (ret && pool->vallocator) {
     GstV4l2Return vret;
 
     vret = gst_v4l2_allocator_stop (pool->vallocator);