flacenc: fix event leak when there is no peer on the src pad
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Fri, 3 Feb 2012 14:53:31 +0000 (14:53 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Fri, 3 Feb 2012 14:53:31 +0000 (14:53 +0000)
ext/flac/gstflacenc.c

index 62065299d8edce3a839ff8ead0638cd4e40ad168..6a7e1c0442dd3931c669dc9b127affabbcf7f8e0 100644 (file)
@@ -883,7 +883,6 @@ gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
     FLAC__uint64 absolute_byte_offset, void *client_data)
 {
   GstFlacEnc *flacenc;
-  GstEvent *event;
   GstPad *peerpad;
 
   flacenc = GST_FLAC_ENC (client_data);
@@ -891,10 +890,9 @@ gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
   if (flacenc->stopped)
     return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
 
-  event = gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES,
-      absolute_byte_offset, GST_BUFFER_OFFSET_NONE, 0);
-
   if ((peerpad = gst_pad_get_peer (GST_AUDIO_ENCODER_SRC_PAD (flacenc)))) {
+    GstEvent *event = gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES,
+        absolute_byte_offset, GST_BUFFER_OFFSET_NONE, 0);
     gboolean ret = gst_pad_send_event (peerpad, event);
 
     gst_object_unref (peerpad);