audiobasesrc: fix ring buffer leak on open failure
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 9 Apr 2015 11:59:38 +0000 (12:59 +0100)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 9 Apr 2015 12:00:57 +0000 (13:00 +0100)
gst-libs/gst/audio/gstaudiobasesrc.c

index 51bb1e7..b529b76 100644 (file)
@@ -1140,8 +1140,13 @@ gst_audio_base_src_change_state (GstElement * element,
       src->ringbuffer = rb;
       GST_OBJECT_UNLOCK (src);
 
-      if (!gst_audio_ring_buffer_open_device (src->ringbuffer))
+      if (!gst_audio_ring_buffer_open_device (src->ringbuffer)) {
+        GST_OBJECT_LOCK (src);
+        gst_object_unparent (GST_OBJECT_CAST (src->ringbuffer));
+        src->ringbuffer = NULL;
+        GST_OBJECT_UNLOCK (src);
         goto open_failed;
+      }
       break;
     }
     case GST_STATE_CHANGE_READY_TO_PAUSED: