rtph264pay: fix potential crash when shutting down
authorPatrick Radizi <patrickr@axis.com>
Thu, 11 Dec 2014 09:16:06 +0000 (10:16 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 11 Dec 2014 14:00:19 +0000 (14:00 +0000)
A race condition in the state change function may cause buffers
to be unreffed while they are still used by the streaming thread
in gst_rtp_h264_pay_send_sps_pps() resulting in a crash. Chain
up to the parent class first in the state change function to
make sure streaming has stopped and only then free those buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=741381

gst/rtp/gstrtph264pay.c

index 8590d99..ba5e4b3 100644 (file)
@@ -1336,6 +1336,13 @@ gst_rtp_h264_pay_change_state (GstElement * element, GstStateChange transition)
       rtph264pay->send_spspps = FALSE;
       gst_adapter_clear (rtph264pay->adapter);
       break;
+    default:
+      break;
+  }
+
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+  switch (transition) {
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       rtph264pay->last_spspps = -1;
       gst_rtp_h264_pay_clear_sps_pps (rtph264pay);
@@ -1344,8 +1351,6 @@ gst_rtp_h264_pay_change_state (GstElement * element, GstStateChange transition)
       break;
   }
 
-  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-
   return ret;
 }