summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2023-11-20 18:47:49 -0600
committerOlivier CrĂȘte <olivier.crete@collabora.com>2023-11-21 08:12:19 -0600
commitd053572c49f1ff5c51740cf6bbc816aadc29087a (patch)
treeb19b0f94669770a2bd70ff92908395ec742a1920
parent504189ed1c325bfeab2e20f606267841661df87c (diff)
nicesink: Protect field access with object lock
Error found by coverity.
-rw-r--r--gst/gstnicesink.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/gst/gstnicesink.c b/gst/gstnicesink.c
index ced4bd0..204d575 100644
--- a/gst/gstnicesink.c
+++ b/gst/gstnicesink.c
@@ -504,24 +504,23 @@ gst_nice_sink_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
- if (sink->agent == NULL)
- {
- GST_ERROR_OBJECT (element,
- "Trying to start Nice sink without an agent set");
- return GST_STATE_CHANGE_FAILURE;
- }
- else if (sink->stream_id == 0)
- {
- GST_ERROR_OBJECT (element,
- "Trying to start Nice sink without a stream set");
- return GST_STATE_CHANGE_FAILURE;
- }
- else if (sink->component_id == 0)
- {
- GST_ERROR_OBJECT (element,
- "Trying to start Nice sink without a component set");
- return GST_STATE_CHANGE_FAILURE;
- }
+ GST_OBJECT_LOCK (element);
+ if (sink->agent == NULL) {
+ GST_ERROR_OBJECT (element,
+ "Trying to start Nice sink without an agent set");
+ goto failure;
+ }
+ else if (sink->stream_id == 0) {
+ GST_ERROR_OBJECT (element,
+ "Trying to start Nice sink without a stream set");
+ goto failure;
+ }
+ else if (sink->component_id == 0) {
+ GST_ERROR_OBJECT (element,
+ "Trying to start Nice sink without a component set");
+ goto failure;
+ }
+ GST_OBJECT_UNLOCK (element);
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
@@ -536,6 +535,10 @@ gst_nice_sink_change_state (GstElement * element, GstStateChange transition)
transition);
return ret;
+
+failure:
+ GST_OBJECT_UNLOCK (element);
+ return GST_STATE_CHANGE_FAILURE;
}
gboolean