GESTimelinePipeline: Handle some trivial error cases
authorEdward Hervey <edward.hervey@collabora.co.uk>
Mon, 29 Aug 2011 10:00:06 +0000 (12:00 +0200)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Mon, 29 Aug 2011 15:43:05 +0000 (17:43 +0200)
Avoids ending up calling potentially NULL variables

ges/ges-timeline-pipeline.c

index 4f84f81..ab1166f 100644 (file)
@@ -139,9 +139,9 @@ ges_timeline_pipeline_init (GESTimelinePipeline * self)
       "avoid-reencoding", TRUE, NULL);
 
   if (G_UNLIKELY (self->priv->playsink == NULL))
-    GST_ERROR_OBJECT (self, "Can't create playsink instance !");
+    goto no_playsink;
   if (G_UNLIKELY (self->priv->encodebin == NULL))
-    GST_ERROR_OBJECT (self, "Can't create encodebin instance !");
+    goto no_encodebin;
 
   /* HACK : Intercept events going through playsink */
   playsinkclass = GST_ELEMENT_GET_CLASS (self->priv->playsink);
@@ -149,6 +149,17 @@ ges_timeline_pipeline_init (GESTimelinePipeline * self)
   playsinkclass->send_event = play_sink_multiple_seeks_send_event;
 
   ges_timeline_pipeline_set_mode (self, DEFAULT_TIMELINE_MODE);
+
+no_playsink:
+  {
+    GST_ERROR_OBJECT (self, "Can't create playsink instance !");
+    return;
+  }
+no_encodebin:
+  {
+    GST_ERROR_OBJECT (self, "Can't create encodebin instance !");
+    return;
+  }
 }
 
 /**
@@ -300,7 +311,7 @@ get_output_chain_for_track (GESTimelinePipeline * self, GESTrack * track)
   return NULL;
 }
 
-/* Fetches a ocmpatible pad on the target element which isn't already
+/* Fetches a compatible pad on the target element which isn't already
  * linked */
 static GstPad *
 get_compatible_unlinked_pad (GstElement * element, GstPad * pad)
@@ -310,6 +321,9 @@ get_compatible_unlinked_pad (GstElement * element, GstPad * pad)
   gboolean done = FALSE;
   GstCaps *srccaps;
 
+  if (G_UNLIKELY (pad == NULL))
+    goto no_pad;
+
   GST_DEBUG ("element : %s, pad %s:%s",
       GST_ELEMENT_NAME (element), GST_DEBUG_PAD_NAME (pad));
 
@@ -358,6 +372,12 @@ get_compatible_unlinked_pad (GstElement * element, GstPad * pad)
   gst_caps_unref (srccaps);
 
   return res;
+
+no_pad:
+  {
+    GST_ERROR ("No pad to check against");
+    return NULL;
+  }
 }
 
 static void